Commit Graph

963 Commits

Author SHA1 Message Date
Andrew Clark
0c756fb33f Update error codes 2018-11-12 17:59:06 -08:00
Sebastian Markbåge
b545546ccb Use unique thread ID for each partial render to access Context (#14182)
* BUG: ReactPartialRenderer / New Context polutes mutable global state

The new context API stores the provided values on the shared context instance. When used in a synchronous context, this is not an issue. However when used in an concurrent context this can cause a "push provider" from one react render to have an effect on an unrelated concurrent react render.

I've encountered this bug in production when using renderToNodeStream, which asks ReactPartialRenderer for bytes up to a high water mark before yielding. If two Node Streams are created and read from in parallel, the state of one can polute the other.

I wrote a failing test to illustrate the conditions under which this happens.

I'm also concerned that the experimental concurrent/async React rendering on the client could suffer from the same issue.

* Use unique thread ID for each partial render to access Context

This first adds an allocator that keeps track of a unique ThreadID index
for each currently executing partial renderer. IDs are not just growing
but are reused as streams are destroyed.

This ensures that IDs are kept nice and compact.

This lets us use an "array" for each Context object to store the current
values. The look up for these are fast because they're just looking up
an offset in a tightly packed "array".

I don't use an actual Array object to store the values. Instead, I rely
on that VMs (notably V8) treat storage of numeric index property access
as a separate "elements" allocation.

This lets us avoid an extra indirection.

However, we must ensure that these arrays are not holey to preserve this
feature.

To do that I store the _threadCount on each context (effectively it takes
the place of the .length property on an array).

This lets us first validate that the context has enough slots before we
access the slot. If not, we fill in the slots with the default value.
2018-11-12 17:50:46 -08:00
Andrew Clark
2dd4ba11e0 ESlint -> ESLint 2018-11-09 10:22:18 -08:00
Sophie Alpert
9cc631a539
Don't run danger on bad build (#14143)
sizebot comments can be confusing when not based on reality.

If results.json doesn't exist, danger will fail. This is what we want.
2018-11-09 10:21:39 -08:00
Andrew Clark
9fb9199455 Add global to ESLint plugin bundle config 2018-11-08 18:49:03 -08:00
Andrew Clark
c174f85924
Add fb build of ESLint plugin (#14165) 2018-11-08 18:44:08 -08:00
Minh Nguyen
3d8bda70e5 Refactor ESLint configuration to enable better IDE integration (#13914)
* Refactor ESLint configuration to enable better IDE integration

* Minor tweaks
2018-11-08 17:56:35 +00:00
Sebastian Markbåge
051272f201
Use Entry in yarn build ... Instead of Label (#14148)
* Parse build script type and package names

This ensures that `yarn build core dom` includes DOM.

It also ensures that spaces like `yarn build "core, dom"` doesn't build EVERYTHING.

* Get rid of label in bundles config

Instead we just use the name from entry using fuzzy search.

There is one special case. If you put in `/index` or `/index.js`.

That allows to build things like `react/index` to only build isomorphic
where as `react` would build everything. Or `react-dom/index` to exclude
the server renderers.

* Instead of matching `/index.js` just append it to the search string

That way things like `yarn build react/` works too.
2018-11-07 20:46:41 -08:00
Brian Vaughn
be63473004
Release script supports interleaved stable and alpha releases (#14138) 2018-11-07 12:33:13 -08:00
Andrew Clark
ba19844236 Update bundle sizes for 16.6.1 release 2018-11-06 18:28:50 -08:00
Andrew Clark
a24d510287 Update error codes for 16.6.1 release 2018-11-06 18:28:50 -08:00
Sebastian Markbåge
fd1256a561
Add Debug Tools Package for Introspection of Hooks (#14085)
* Add debug tools package

* Add basic implementation

* Implement inspection of the current state of hooks using the fiber tree

* Support useContext hooks inspection by backtracking from the Fiber

I'm not sure this is safe because the return fibers may not be current
but close enough and it's fast.

We use this to set up the current values of the providers.

* rm copypasta

* Use lastIndexOf

Just in case. I don't know of any scenario where this can happen.

* Support ForwardRef

* Add test for memo and custom hooks

* Support defaultProps resolution
2018-11-05 10:02:59 -08:00
Keyan Zhang
ce90ffd045 update the benchmark script (#13994) 2018-11-05 15:55:46 +00:00
Caleb Meredith
ddbfe2ed50 Add ESLint rule for React Hooks 2018-10-29 11:26:54 -07:00
Dan Abramov
8b97a9c36f Update bundle sizes for 16.6.0 release 2018-10-23 16:29:35 -07:00
Dan Abramov
c8ade996e9 Update error codes for 16.6.0 release 2018-10-23 16:29:35 -07:00
Brian Vaughn
ff5efb0390 Prettier 2018-10-23 15:06:58 -07:00
Brian Vaughn
f4488bee51
Add skipCI flag to release script (#13933) 2018-10-23 15:05:14 -07:00
Andrew Clark
d8e03de4aa
[react-cache] Remove cache as argument to read (#13865)
* [react-cache] Remove `cache` as argument to `read`

Updated is API is `Resource.read(key)` instead of
`Resource.read(cache, key)`.

The cache is read from context using `readContext`.

This also removes cache invalidation entirely (other than the default
LRU mechanism), as well as the ability to have multiple caches. We'll
add it back once `Context.write` lands and we can implement it the
right way.

Since there's now only a single cache (the global one), we don't
actually need to use context yet, but I've added a dummy context
anyway so the user gets an error if they attempt to read outside the
render phase.

* nits

* Add test for thenables that resolve multiple times
2018-10-23 14:38:51 -07:00
Brian Vaughn
915e4eab53
Add "unstable_" prefix to react-cache and jest-react (#13929)
* Add "unstable_" prefix to react-cache createResource and jest-react matchers
* Reverted accidental change to error-codes JSON
* Remove unstable_ prefix from internal React tests for jest-test
2018-10-23 13:55:37 -07:00
Abdul Rauf
420001cb4e Fix babel-preset-fbjs configure link in comment (#13666) 2018-10-21 12:23:24 -05:00
Nadia Osipova
a165cf7473 Renamed 4 Internal React Modules 2018-10-11 17:12:31 -07:00
Dan Abramov
0af8199709 Revert "comment out temporarily"
This reverts commit 9abb9cd50a.
2018-10-10 17:23:18 +01:00
Dan Abramov
c73497c3c7 Update bundle sizes for 16.6.0-alpha.8af6728 release 2018-10-10 17:19:00 +01:00
Dan Abramov
101ea6b84d Update error codes for 16.6.0-alpha.8af6728 release 2018-10-10 17:18:59 +01:00
Dan Abramov
9abb9cd50a comment out temporarily 2018-10-10 17:11:44 +01:00
Andrew Clark
96bcae9d50
Jest + test renderer helpers for concurrent mode (#13751)
* Jest + test renderer helpers for concurrent mode

Most of our concurrent React tests use the noop renderer. But most
of those tests don't test the renderer API, and could instead be
written with the test renderer. We should switch to using the test
renderer whenever possible, because that's what we expect product devs
and library authors to do. If test renderer is sufficient for writing
most React core tests, it should be sufficient for others, too. (The
converse isn't true but we should aim to dogfood test renderer as much
as possible.)

This PR adds a new package, jest-react (thanks @cpojer). I've moved
our existing Jest matchers into that package and added some new ones.

I'm not expecting to figure out the final API in this PR. My goal is
to land something good enough that we can start dogfooding in www.

TODO: Continue migrating Suspense tests, decide on better API names

* Add additional invariants to prevent common errors

- Errors if user attempts to flush when log of yields is not empty
- Throws if argument passed to toClearYields is not ReactTestRenderer

* Better method names

- toFlushAll -> toFlushAndYield
- toFlushAndYieldThrough ->
- toClearYields -> toHaveYielded

Also added toFlushWithoutYielding

* Fix jest-react exports

* Tweak README
2018-10-03 18:37:41 -06:00
Brian Vaughn
36c5d69caa
Always warn about legacy context within StrictMode tree (#13760) 2018-10-03 08:40:45 -07:00
Maksim Markelov
3e9a5de888 UMD react-cache build (#13761) 2018-10-03 15:09:17 +01:00
Andrew Clark
ce96e2df4d
Rename simple-cache-provider to react-cache (#13755) 2018-10-01 09:07:40 -06:00
Dan
eeb817785c Remove some old files from stats 2018-09-19 01:36:31 +01:00
Dan Abramov
7ea3ca1d13
Rename schedule to scheduler (#13683) 2018-09-19 01:26:28 +01:00
Brian Vaughn
bec2ddaf15 Update bundle sizes for 16.5.2 release 2018-09-18 11:30:50 -07:00
Brian Vaughn
789e714bd7 Update error codes for 16.5.2 release 2018-09-18 11:30:50 -07:00
Brian Vaughn
39f93f7987 Revert "Update error codes for 16.6.0-alpha.0 release"
This reverts commit 21ceb19ea0.
2018-09-18 11:00:04 -07:00
Brian Vaughn
c3fad5acf8 Revert "Update bundle sizes for 16.6.0-alpha.0 release"
This reverts commit 42d12317a7.
2018-09-18 10:59:57 -07:00
Brian Vaughn
42d12317a7 Update bundle sizes for 16.6.0-alpha.0 release 2018-09-17 15:05:46 -07:00
Brian Vaughn
21ceb19ea0 Update error codes for 16.6.0-alpha.0 release 2018-09-17 15:05:46 -07:00
Brian Vaughn
8bc0bcabe7
Add UMD production+profiling entry points (#13642)
* Added UMD_PROFILING type to react-dom and scheduling package. Added UMD shim to schedule package.
* Added new schedule umd prod+prof bundle to API test
2018-09-13 17:44:08 -07:00
Brian Vaughn
4bcee56210
Rename "tracking" API to "tracing" (#13641)
* Replaced "tracking" with "tracing" in all directory and file names
* Global rename of track/tracking/tracked to trace/tracing/traced
2018-09-13 14:23:16 -07:00
Dan Abramov
72217d0819 Update bundle sizes for 16.5.1 release 2018-09-13 19:31:18 +01:00
Dan Abramov
cc66a1aa23 Update error codes for 16.5.1 release 2018-09-13 19:31:18 +01:00
Dan Abramov
2282400850
Delete TapEventPlugin (#13630) 2018-09-12 19:53:29 +01:00
Nathan Hunzaker
a079011f95 🔥 Stop syncing the value attribute on inputs (behind a feature flag) (#13526)
* 🔥 Stop syncing the value attribute on inputs

* Eliminate some additional checks

* Remove initialValue and initialWrapper from wrapperState flow type

* Update tests with new sync logic, reduce some operations

* Update tests, add some caveats for SSR mismatches

* Revert newline change

* Remove unused type

* Call toString to safely type string values

* Add disableInputAttributeSyncing feature flag

Reverts tests to original state, adds attribute sync feature flag,
then moves all affected tests to ReactFire-test.js.

* Revert position of types in toStringValues

* Invert flag on number input blur

* Add clarification why double blur is necessary

* Update ReactFire number cases to be more explicite about blur

* Move comments to reduce diff size

* Add comments to clarify behavior in each branch

* There is no need to assign a different checked behavior in Fire

* Use checked reference

* Format

* Avoid precomputing stringable values

* Revert getToStringValue comment

* Revert placement of undefined in getToStringValue

* Do not eagerly stringify value

* Unify Fire test cases with normal ones

* Revert toString change. Only assign unsynced values when not nully
2018-09-12 19:29:23 +01:00
Dan Abramov
a7bd7c3c04
Allow reading default feature flags from bundle tests (#13629) 2018-09-12 16:56:04 +01:00
Dan Abramov
7204b636ee
Run tests for Fire feature flags (#13628)
* Run tests for Fire feature flags

* Only run ReactDOM tests for Fire
2018-09-12 16:17:36 +01:00
Héctor Ramos
dde0645fcf Switch to @sizebot token (#13622) 2018-09-11 21:06:44 +01:00
Brian Vaughn
54bfab5d6d
Release script updates private package dependencies also (#13612) 2018-09-10 13:14:34 -07:00
Dan
8a8d973d3c Use clearer wording
Fixes #13604
2018-09-09 16:54:31 +01:00
Brandon Dail
7d1169b2d7
Remove injectComponentTree from unstable-native-dependencies, add EventPluginHub (#13598)
* Remove injectComponentTree from unstable-native-dependencies, add
EventPluginHub

injectComponentTree was exposed for react-native-web, but wasn't
actually being used by the project. They were using EventPluginHub
through ReactDOM's secret internals, but that was removed in https://github.com/facebook/react/pull/13539

This removes the unused injectComponentTree export, refactors the
ResponderEventPlugin test so it doesn't depend on it, and also adds
EventPluginHub to the exports to unbreak react-native-web

* Re-export injectEventPluginsByName from ReactDOM internals
2018-09-08 12:07:59 -07:00