Commit Graph

10472 Commits

Author SHA1 Message Date
Dominic Gannaway
aa1ffe4e77 Show deprecated context object warnings usage in ReactDOM server (#14033)
* Applies context object warnings to ReactDOM server
2018-11-07 17:19:38 +00:00
Andrew Clark
e3a7b96455 Make react-debug-tools a private package 2018-11-06 18:45:30 -08:00
Andrew Clark
ff29de4029 Updating CHANGELOG.md for 16.6.1 release 2018-11-06 18:32:29 -08:00
Andrew Clark
ba19844236 Update bundle sizes for 16.6.1 release v16.6.1 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
Andrew Clark
b50e63ef53 Updating package versions for release 16.6.1 2018-11-06 18:19:57 -08:00
Andrew Clark
fd4527dbcd Updating yarn.lock file for 16.6.1 release 2018-11-06 18:16:23 -08:00
Andrew Clark
bd5a6d3914 Update changelog with unreleased features 2018-11-06 17:38:19 -08:00
Andrew Clark
8f2c89e963 Make react-debug-tools a private package 2018-11-06 17:37:52 -08:00
locknono
2aecbcd6f1 "functional component" -> "function component" (#14123) 2018-11-06 17:33:26 -08:00
Nadav Kaner
b4608dd24c Remove unused simulated flag parameter (#14127) 2018-11-06 17:33:01 -08:00
Dan Abramov
3c69a18814 Recover from errors with a boundary in completion phase (#14104)
* Recover from errors with a boundary in completion phase

* Use a separate field for completing unit of work

* Use a simpler fix with one boolean

* Reoder conditions

* Clarify which paths are DEV-only

* Move duplicated line out

* Make it clearer this code is DEV-only
2018-11-06 23:38:12 +00:00
Andrew Clark
b020fb1148 Check correct commit phase props in fuzz tester (#14129)
Adds a check to the existing fuzz tester to confirm that the props are
set to the latest values in the commit phase. Only checks
componentDidUpdate; we already have unit tests for the other lifecycles,
so I think this is good enough. This is only a redundancy.
2018-11-06 15:01:18 -08:00
Dan Abramov
b67c1a2ee1 Add DEV-only checks for assumption about instance properties (#14128) 2018-11-06 22:28:50 +00:00
Dan Abramov
f777d196e0 Fix lazy() with defaultProps (#14112)
* Resolve defaultProps for Lazy components

* Make test fail again

* Undo the partial fix

* Make test output more compact

* Add a separate failing test for sync mode

* Clean up tests

* Add another update to both tests

* Resolve props for commit phase lifecycles

* Resolve prevProps for begin phase lifecycles

* Resolve prevProps for pre-commit lifecycles

* Only resolve props if element type differs

* Fix Flow

* Don't set instance.props/state during commit phase

This is an optimization. I'm not sure it's entirely safe. It's probably worth running internal tests and see if we can ever trigger a case where they're different.

This can mess with resuming.

* Keep setting instance.props/state before unmounting

This reverts part of the previous commit. It broke a test that verifies we use current props in componentWillUnmount if the fiber unmounts due to an error.
2018-11-06 19:54:14 +00:00
Sophie Alpert
e4512991c9 Fix unhiding in IE11 (#14126)
Setting to null isn't correct; setting to '' is. I opted to use dangerousStyleValue for consistency with the main path that we set things.

Fixes #14114.

Test Plan:
Verified setting to '' works in Chrome and IE11. (Setting to null works in Chrome but not in IE11.)
2018-11-06 11:24:44 -08:00
Andrew Clark
affb2b50ca Enable hooks in www test renderer, too 2018-11-05 18:50:00 -08:00
Andrew Clark
0a0f503d57 Enable hooks in www build (#14116)
The `enableHooks` feature flag used to only control whether the API
was exposed on the React package. But now it also determines if the
dispatcher and implementation are included in the bundle.

We're using hooks in www, so I've switched the feature flag to `true`
in the www build.

(Alternatively, we could have two feature flags: one for the
implementation and dispatcher, and one for exposing the API on the
React package.)
2018-11-05 17:48:54 -08:00
Dan Abramov
600651e68e Restore the Hooks dispatcher after using SSR (#14105) 2018-11-06 01:15:11 +00:00
Andrew Clark
e9a2ec9156 [suspense] Avoid double commit by re-rendering immediately and reusing primary children (#14083)
* Avoid double commit by re-rendering immediately and reusing children

To support Suspense outside of concurrent mode, any component that
starts rendering must commit synchronously without being interrupted.
This means normal path, where we unwind the stack and try again from the
nearest Suspense boundary, won't work.

We used to have a special case where we commit the suspended tree in an
incomplete state. Then, in a subsequent commit, we re-render using the
fallback.

The first part — committing an incomplete tree — hasn't changed with
this PR. But I've changed the second part — now we render the fallback
children immediately, within the same commit.

* Add a failing test for remounting fallback in sync mode

* Add failing test for stuck Suspense fallback

* Toggle visibility of Suspense children in mutation phase, not layout

If parent reads visibility of children in a lifecycle, they should have
already updated.
2018-11-05 16:32:50 -08:00
Sophie Alpert
9d47143e85 Implement {,un}hideInstance on RN renderer (#14115)
This is required to use lazy.

Test Plan:
* Verified lazy works on a real world use case (shows spinner, shows real content).
* Verified that if I change the primary content's styles to have `display: 'none'` then it never appears (i.e., the code in `unhide` reads the styles successfully)
2018-11-05 15:33:25 -08:00
Sophie Alpert
ebdb47d2c1 DCE hooks code when flag is off (#14111) 2018-11-05 13:04:57 -08:00
Sophie Alpert
8b87ebf5b0 Rename .internal tests that aren't using internals (#14109) 2018-11-05 11:12:28 -08:00
Sophie Alpert
da04058a91 Use Function.prototype.apply in warningWithoutStack (#14107)
console.error.apply() fails in IE9, but I verified this works (and it works everywhere else too). :)
2018-11-05 11:11:33 -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
Tiago Nunes
b305c4e034 fix(react-dom): Fix crash during server render (#14103)
Check for existence of `setTimeout` and `clearTimeout` in the runtime
before using them, to ensure runtimes without them (like .NET ClearScript)
do not crash just by importing `react-dom`.
2018-11-05 17:08:07 +00:00
Keyan Zhang
ce90ffd045 update the benchmark script (#13994) 2018-11-05 15:55:46 +00:00
Marcelo Jorge Vieira
d34d1c3bae react-reconciler: Update README.md (#13953)
Replaced 'var' with 'const'
2018-11-05 15:55:23 +00:00
einarq
6c404d82aa Bugfix: Add back early return in setOffsets which was removed between 16.4.2 and 16.5.0. Fails in Edge in some scenarios. (#14095) 2018-11-05 15:19:50 +00:00
Simen Bekkhus
8eca0eff87 chore(tests): don't rely on jest fake timers scheduling real timers (#14003)
* chore: don't rely on jest fake timers scheduling real timers

* re-add one part not working with Jest 23
2018-11-02 16:54:23 -05:00
Sophie Alpert
293fed8993 Warn for bad useEffect return value (#14069)
Mostly to catch this:

```js
useEffect(async () => {
  // ...
  return cleanup;
});
```

Is this too restrictive? Not sure if you would want to do like

```js
useEffect(() => ref.current.style.color = 'red');
```

which would give a false positive here. We can always relax it to only warn on Promises if people complain.
2018-11-02 14:43:45 -07:00
Mateusz Burzyński
ae196e84b6 Rename inputsAreEqual to areHookInputsEqual & move it to shared (#14036) 2018-11-02 12:50:23 -07:00
Sophie Alpert
c898020e01 Warn for forwardRef(memo(...)) (#14070)
People are probably gonna do this all the time.
2018-11-02 12:32:44 -07:00
Sophie Alpert
c84b9bf828 Tweak error message for missing fallback (#14068) 2018-11-01 22:45:23 -07:00
Chris Bianca
595b4f945b Remove duplicate import declarations (#14062) 2018-11-01 13:31:46 +00:00
Maksim Markelov
d5d10d140e Simplify imports in react reconciler (#13718)
* Simplify imports in ReactChildFiber
* Import type first in ReactCurrentFiber
* Simplify imports in ReactFiberBeginWork
* Simplify imports in ReactFiberScheduler
* Simplify import in ReactFiberTreeReflection
* Simplify import in ReactFiberUnwindWork
* Remove repeated import
* Fix imports from ReactFiberExpirationTime
* Master imports in ReactFiberBeginWork
2018-10-31 21:12:51 -07:00
Jordan Harband
cdbfa6b5dd [react-is] add back proper AsyncMode symbol, for back compat (#13959)
- Partial revert of #13732
 - Fixes #13958.
2018-10-31 19:03:50 +00:00
Brian Vaughn
1ae3f29c20 Fix react-cache UMD build (#14047) 2018-10-31 11:16:03 -07:00
Sophie Alpert
3db8b80e15 Don't lint against Hooks after conditional throw (#14040)
Seems like this should be OK. Fixes #14038.

Now when tracking paths, we completely ignore segments that end in a throw.
2018-10-30 17:13:24 -07:00
Sophie Alpert
169f935f78 Flip expiration times (#13912)
See https://github.com/facebook/react/pull/13912 commit messages for how this was done.
2018-10-30 15:26:20 -07:00
Andrew Clark
bf9fadfcf4 [Hooks] Remove dispatch callbacks (#14037)
Removes the `enableDispatchCallback` feature flag and deletes the
associated code. An earlier version of the Hooks proposal included this
feature but we've since decided to remove it.
2018-10-30 14:14:20 -07:00
Andrew Clark
8c67bbf183 [scheduler] Deadline object -> shouldYield (#14025)
* [scheduler] Deadline object -> shouldYield

Instead of using a requestIdleCallback-style deadline object, expose a
method Scheduler.shouldYield that returns true if there's a higher
priority event in the queue.

* Nits
2018-10-30 13:47:51 -07:00
Andrew Clark
e02086bfcc Warn about variable number of dependencies
We don't check this in prod, since best practice is to always pass
these inline. But we should still warn in dev.
2018-10-29 13:51:43 -07:00
Andrew Clark
b92cdef641 Rename ReactHooks test suite
New tests should use React Test Renderer. We'll put existing tests in
this module and new tests in a new module.
2018-10-29 13:36:41 -07:00
Sophie Alpert
6efbbe0685 Prettier 2018-10-29 12:29:41 -07:00
Andrew Clark
5045763064 Swap order of function member in hook union types 2018-10-29 11:42:41 -07:00
Caleb Meredith
ddbfe2ed50 Add ESLint rule for React Hooks 2018-10-29 11:26:54 -07:00
Andrew Clark
acb4899637 Clear effect tags from a fiber that suspends in non-concurrent mode
Even though we commit the fiber in an incomplete state, we shouldn't
fire any lifecycles or effects.

We already did this for classes, but now with useEffect, the same is
needed for other types of work, too.
2018-10-29 11:26:54 -07:00
Andrew Clark
933b64710a Disable hook update callback (2nd arg to setState/dispatch)
I put the feature behind a feature flag, along with a warning, so
we can phase it out in www.
2018-10-29 11:26:54 -07:00
Sophie Alpert
5fc84efacc Skip updating effect tag when skipping effect
For example, if you have `useEffect(..., [])`, there's no need to set .effectTag to `Update | Passive` on updates.
2018-10-29 11:26:54 -07:00