Commit Graph
9750 Commits
Author SHA1 Message Date
Brian Vaughn 1c895fbc76 Updating package versions for release 16.3.0 2018-03-29 13:03:33 -07:00
Brian VaughnandGitHub 6bfd14f632 unstable_createRoot (#12487)
* Removed enableCreateRoot flag. Renamed createRoot to unstable_createRoot

* ReactDOMRoot test is no longer internal
2018-03-29 12:51:34 -07:00
Dan AbramovandGitHub 607bcd9241 Disable createRoot for open source builds (#12486) 2018-03-29 20:25:20 +01:00
Brian Vaughn b75e3de86c Updated react-is README to show new isValidElementType() 2018-03-29 11:46:18 -07:00
James ReggioandBrian Vaughn baa1e1cd09 Add React.isValidElementType() (#12483)
* Add React.isValidElementType()

Per the conversation on #12453, there are a number of third-party
libraries (particularly those that generate higher-order components)
that are performing suboptimal validation of element types.

This commit exposes a function that can perform the desired check
without depending upon React internals.

* Move isValidElementType to shared/
2018-03-29 11:45:41 -07:00
Flarnie MarchanandGitHub 990c71cf4d Update user timing to record the timeout deadline with 'waiting' events (#12479)
* Update user timing to record the timeout deadline with 'waiting' events

**what is the change?:**
When we are processing work during reconciliation, we have a "timeout"
deadline to finish the work. It's a safety measure that forces things to
finish up synchronously if they are taking too long.

The "timeout" is different depending on the type of interaction which
triggered the reconciliation. We currently have a shorter "timeout" for
"interactive updates", meaning we will try to finish work faster if the
reconciliation was triggered by a click or other user interaction.

For collecting more data in our logs we want to differentiate the
'waiting for async callback...' events based on the "timeout" so I'm
adding that to the logging.

One interesting note - in one of the snapshot tests the "timeout" was
super high. Going to look into that.

**why make this change?:**
Right now we are debugging cases where an interaction triggers a
reconciliation and the "waiting for async callback...' events are too
long, getting blocked because the main thread is too busy. We are
keeping logs of these user timing events and want to filter to focus on
the reconciliation triggered by interaction.

**test plan:**
Manually tested and also updated snapshot tests.

(Flarnie will insert a screenshot)

* Improve wording of message

* ran prettier
2018-03-29 11:26:11 -07:00
Dustan KastenandDan Abramov dd07d2fe51 Don't bail out on referential equality of Consumer's props.children function (#12470)
* Test case for React Context bailing out unexpectedly

* This is 💯% definitely not the correct fix at all

* Revert "This is 💯% definitely not the correct fix at all"

This reverts commit 8686c0f6bdc1cba3056fb2212f3f7740c749d33a.

* Formatting + minor tweaks to the test

* Don't bail out on consumer child equality

* Tweak the comment

* Pretty lint

* Silly Dan
2018-03-29 19:16:02 +01:00
Sophie AlpertandDan Abramov 99e803e8d3 Improve warning message for setState-on-unmounted (#12347)
This is one of the most common warnings people see, and I don't think the old text is especially clear. Improve it.
2018-03-29 16:21:22 +01:00
Dan AbramovandGitHub 4f133ea882 setState() in componentDidMount() should flush synchronously even with createBatch() (#12466)
* Add a failing test for setState in cDM during batch.commit()

* Copy pasta

* Flush all follow-up Sync work on the committed batch

* Nit: Use performSyncWork

Call performSyncWork right after flushing the batch. Does effectively
the same thing by reusing the existing function.

Also added some comments.

* Delete accidentally duplicated test
2018-03-29 02:41:42 +01:00
Andrew ClarkandGitHub 03b77d2cfc Fix bug when fatal error is thrown as a result of batch.commit (#12480)
Fixes #12474
2018-03-28 18:18:09 -07:00
Andrew ClarkandGitHub 44de2c3251 Add unstable APIs for async rendering to test renderer (#12478)
These are based on the ReactNoop renderer, which we use to test React
itself. This gives library authors (Relay, Apollo, Redux, et al.) a way
to test their components for async compatibility.

- Pass `unstable_isAsync` to `TestRenderer.create` to create an async
renderer instance. This causes updates to be lazily flushed.
- `renderer.unstable_yield` tells React to yield execution after the
currently rendering component.
- `renderer.unstable_flushAll` flushes all pending async work, and
returns an array of yielded values.
- `renderer.unstable_flushThrough` receives an array of expected values,
begins rendering, and stops once those values have been yielded. It
returns the array of values that are actually yielded. The user should
assert that they are equal.

Although we've used this pattern successfully in our own tests, I'm not
sure if these are the final APIs we'll make public.
2018-03-28 14:57:25 -07:00
Brian VaughnandGitHub cf0d83169f Added DEV warning if getSnapshotBeforeUpdate is defined as a static method (#12475) 2018-03-28 13:35:32 -07:00
NikolayandNathan Hunzaker 4162406f47 Fix typo in create-subscription readme
PR: #12473
2018-03-28 08:51:16 -04:00
Brian VaughnandGitHub 33738b790c Fix build script to handle react-is (no peer deps) (#12471) 2018-03-27 19:19:34 -07:00
Brian Vaughn 0a41c3fafa Update bundle sizes for 16.3.0-rc.0 release 2018-03-27 19:11:20 -07:00
Brian Vaughn cdeccca6ae Updating dependencies for react-noop-renderer 2018-03-27 19:07:53 -07:00
Brian Vaughn 8fc13f1972 Updating package versions for release 16.3.0-rc.0 2018-03-27 19:07:53 -07:00
Andrew ClarkandGitHub 3cafb056b1 Caveat about async in create-subscription README (#12469)
* Caveat about async in create-subscription README

* Address Sophie's comments

* Dan's nits
2018-03-27 16:50:12 -07:00
Brian VaughnandGitHub ca51548fb0 Call getSnapshotBeforeUpdate before mutation (#12468)
* Call getSnapshotBeforeUpdate in separate traversal, before mutation (aka revert db84b9a) and add unit test.

* Added a new timer to ReactDebugFiberPerf for Snapshot effects
2018-03-27 15:37:13 -07:00
Brian VaughnandGitHub f96c7d6326 Rename react-is import alias in FB bundles (#12459) 2018-03-27 08:57:11 -07:00
Brian VaughnandGitHub 9da74bb21e Include react-is in FB build targets (#12458) 2018-03-26 16:56:06 -07:00
Brian VaughnandGitHub 3671a8c8c2 New commit phase lifecycle: getSnapshotBeforeUpdate (#12404)
* Implemented new getSnapshotBeforeUpdate lifecycle
* Store snapshot value from Fiber to instance (__reactInternalSnapshotBeforeUpdate)
* Use commitAllHostEffects() traversal for getSnapshotBeforeUpdate()
* Added DEV warnings and tests for new lifecycle
* Don't invoke legacy lifecycles if getSnapshotBeforeUpdate() is defined. DEV warn about this.
* Converted did-warn objects to Sets in ReactFiberClassComponent
* Replaced redundant new lifecycle checks in a few methods
* Check for polyfill suppress flag on cWU as well before warning
* Added Snapshot bit to HostEffectMask
2018-03-26 13:28:10 -07:00
Brian VaughnandGitHub 33c2306a86 Workaround jest-diff single line string limitation (#12456) 2018-03-26 10:48:36 -07:00
Jason QuenseandDan Abramov eb94519de0 Remove dependency on React (#12448)
Is this necessary? I'd like to use the package in enzyme to avoid having to recopy/paste the symbols for better debugging names, but at hard dep in enzyme proper on a version of react isn't gonna work. This seems safe since nothing explicitly depends on React in here?
2018-03-24 16:59:36 +00:00
Dan AbramovandGitHub 1c572ac7d6 Don't pass a Fiber to showErrorDialog() (#12445)
* Don't pass a Fiber to showErrorDialog()

* Only fill in the fields for classes

* Reorder for clarity
2018-03-23 21:52:53 +00:00
Maël NisonandDan Abramov 29f98c7be2 Tweaks the build script (#12444)
Branch: build-tweaks
2018-03-23 19:51:04 +00:00
Maël NisonandDan Abramov 670a8dd06c Adds semver to the package dev dependencies (#12442)
Branch: semver
2018-03-23 19:31:16 +00:00
Rene Hangstrup MøllerandDan Abramov 74b79599f1 Rename bits to unstable_observedBits (#12440) 2018-03-23 15:58:49 +00:00
Brian Vaughn 015f5f29a3 Update bundle sizes for 16.3.0-alpha.3 release 2018-03-22 12:45:10 -07:00
Brian Vaughn 7e470376f4 Updating dependencies for react-noop-renderer 2018-03-22 12:41:43 -07:00
Brian Vaughn 95ec465fdd Updating package versions for release 16.3.0-alpha.3 2018-03-22 12:41:43 -07:00
Brian VaughnandGitHub 0877a850b4 Removed dev warnings from shallow renderer. (#12433) 2018-03-22 11:32:37 -07:00
Brian VaughnandGitHub ecb2d47ffe Expanded DEV-only warnings for gDSFP and legacy lifecycles (#12419) 2018-03-22 11:16:54 -07:00
Dan AbramovandGitHub a864da9d0e Warn about non-static getDerivedStateFromProps/Catch (#12431) 2018-03-22 17:54:51 +00:00
Dan AbramovandGitHub 50b12943cf Use "Component" as fallback name in more places (#12430) 2018-03-22 17:26:46 +00:00
Dan AbramovandGitHub 7cfcf460f5 Add a fallback component name for warnings (#12429) 2018-03-22 17:22:13 +00:00
Brian VaughnandGitHub 32ff7da9ac Subscriptions shouldn't call setState after unmount even for Promises (#12425) 2018-03-22 08:54:57 -07:00
Rajendra aroraandDan Abramov a02c3614e6 Removed documentation badge from readme.md (#12424)
* Added badge for react documentation

* Updated reference documentation link for badge

* Update README.md

* Update README.md

* Update README.md

* Removed reference badge from Readme.md
2018-03-22 15:48:52 +00:00
Brian VaughnandGitHub 91f2e160eb Fixed a batched-state update bug with getDerivedStateFromProps (#12408) 2018-03-21 11:42:52 -07:00
Rajendra aroraandNathan Hunzaker f79b2688c7 Added badge for react documentation (#12191)
* Added badge for react documentation

* Updated reference documentation link for badge
2018-03-21 13:05:02 -04:00
Dan AbramovandGitHub fb031fe5c5 Fix now-missing errorInfo argument to componentDidCatch() (#12416)
* Add a failing test verifying componentInfo is missing

* Pass componentInfo to componentDidCatch and getDerivedStateFromCatch

* Only expect stack in DEV

* Don't pass the stack to getDerivedStateFromCatch()
2018-03-21 16:38:24 +00:00
Léo AndrèsandNathan Hunzaker f80535a5b1 Clean shell scripts (#12365) 2018-03-21 12:03:09 -04:00
Barry Michael DoyleandNathan Hunzaker 19eed9f21e Replaced object building loop with Object.assign function (#12414) 2018-03-21 09:45:45 -04:00
VasiliyandDan Abramov 70beaded6a Fix falling in dev mode (#12407)
FiberNode stateNode could be null

So I get TypeError:

```
  at performWorkOnRoot (/tmp/my-project/node_modules/react-dom/cjs/react-dom.development.js:11014:24) TypeError: Cannot read property '_warnedAboutRefsInRender' of null
          at findDOMNode (/tmp/my-project/node_modules/react-dom/cjs/react-dom.development.js:15264:55)
```
2018-03-21 09:41:50 +00:00
Dan Abramov 2c3050b117 Fix Prettier 2018-03-21 09:41:23 +00:00
Kevin GozaliandDan Abramov a4e228665b [fabric] register ReactFabric to be callable module (#12405) 2018-03-20 14:56:18 +00:00
Dan AbramovandGitHub 2d3f2308bf Fix an infinite loop in new context (#12402)
* Add a regression test for the context infinite loop

* Fix the bug

We set .return pointer inside the loop, but the top-level parent-child relationship happens outside.

This ensures the top-level parent's child points to the right copy of the parent.

Otherwise we may end up in a situation where (workInProgress === nextFiber) is never true and we loop forever.
2018-03-20 13:06:59 +00:00
Jason QuenseandBrian Vaughn 1d33d6f54c Support ForwardRef type of work in TestRenderer (#12392)
* Support ForwardRef type of work in TestRenderer and ShallowRenderer.
* Release script now updates inter-package dependencies too (e.g. react-test-renderer depends on react-is).
2018-03-16 11:18:50 -07:00
Andrew ClarkandGitHub fd6adeafa9 Feature flag: Use custom requestIdleCallback even when native one exists (#12385)
We'll use this in www to test whether the polyfill is better at
scheduling high-pri async work than the native one. My preliminary tests
suggest "yes" but it's hard to say for certain, given how difficult it
is to consistently reproduce the starvation issues we've been seeing.
2018-03-15 19:28:21 -07:00
Andrew ClarkandGitHub eab96315e9 Unify context stack implementations (#12359)
* Use module pattern so context stack is isolated per renderer

* Unify context implementations

Implements the new context API on top of the existing ReactStack that we
already use for host context and legacy context. Now there is a single
array that we push and pop from.

This makes the interrupt path slightly slower, since when we reset the
unit of work pointer, we have to iterate over the stack (like before)
*and* switch on the type of work (not like before). On the other hand,
this unifies all of the unwinding behavior in the UnwindWork module.

* Add DEV only warning if stack is not reset properly
2018-03-15 19:27:44 -07:00