Tiago Nunes and Dan Abramov
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 and Dan Abramov
ce90ffd045
update the benchmark script ( #13994 )
2018-11-05 15:55:46 +00:00
Marcelo Jorge Vieira and Dan Abramov
d34d1c3bae
react-reconciler: Update README.md ( #13953 )
...
Replaced 'var' with 'const'
2018-11-05 15:55:23 +00:00
einarq and Dan Abramov
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 and Nathan Hunzaker
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 and GitHub
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 and Sophie Alpert
ae196e84b6
Rename inputsAreEqual to areHookInputsEqual & move it to shared ( #14036 )
2018-11-02 12:50:23 -07:00
Sophie Alpert and GitHub
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 and GitHub
c84b9bf828
Tweak error message for missing fallback ( #14068 )
2018-11-01 22:45:23 -07:00
Chris Bianca and Dan Abramov
595b4f945b
Remove duplicate import declarations ( #14062 )
2018-11-01 13:31:46 +00:00
Maksim Markelov and Nathan Hunzaker
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 and Dan Abramov
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 and GitHub
1ae3f29c20
Fix react-cache UMD build ( #14047 )
2018-10-31 11:16:03 -07:00
Sophie Alpert and GitHub
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 and GitHub
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 and GitHub
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 and GitHub
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 and Andrew Clark
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 and 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 and Andrew Clark
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
Alex Taylor and Andrew Clark
9f34eb79a3
Add readContext to ReactPartialRendererHooks
2018-10-29 11:26:54 -07:00
Dan Abramov and Andrew Clark
f7cb9d2b22
Warn about useContext(Consumer|Provider)
2018-10-29 11:26:54 -07:00
Dan Abramov and Andrew Clark
63cc7d2b31
Test useContext in pure, forwardRef, and PureComponent
2018-10-29 11:26:54 -07:00
Sophie Alpert and Andrew Clark
3a7c6da8d4
Make effects actually work with memo
...
Bug fix.
2018-10-29 11:26:54 -07:00
Sophie Alpert and Andrew Clark
75a1c2e72a
The Lost Effect, chapter 3
...
wow, writing code is hard
2018-10-29 11:26:54 -07:00
Sophie Alpert and Andrew Clark
55a4b1f377
memo supports Hooks
2018-10-29 11:26:53 -07:00
Sophie Alpert and Andrew Clark
30aa4ad554
The Lost Effect, chapter 2
...
Previously, flushPassiveEffects (called by scheduling work) would overwrite rootWithPendingPassiveEffects before we had a chance to schedule the work.
2018-10-29 11:26:53 -07:00
Sebastian Markbåge and Andrew Clark
b772e0e26b
"functional component" -> "function component" in hooks error messages
2018-10-29 11:26:53 -07:00
Sophie Alpert and Andrew Clark
9e9e3970e4
Warn for Hook set-state on unmounted component
2018-10-29 11:26:53 -07:00
Sophie Alpert and Andrew Clark
6514697f0c
Make sure deletions don't stop passive effects
...
Before the fix, the passive effect in the test is never executed.
We were previously waiting until the next commit phase to run effects. Now, we run them before scheduling work.
2018-10-29 11:26:53 -07:00
dd019d34db
Add support for hooks to ReactDOMServer
...
Co-authored-by: Alex Taylor <alexmckenley@gmail.com >
Co-authored-by: Andrew Clark <acdlite@fb.com >
2018-10-29 11:26:53 -07:00
Andrew Clark and Andrew Clark
11d0781eea
Defer useEffect until after paint
...
Effects scheduled by useEffect should not fire until after the browser
has had a chance to paint. However, they should be fired before any
subsequent mutations.
Also adds useMutationEffect and useLayoutEffect. useMutationEffect fires
during the host update phase. useLayoutEffect fires during the post-
update phase (the same phase as componentDidMount
and componentDidUpdate).
2018-10-29 11:26:53 -07:00
Andrew Clark and Andrew Clark
105f2de545
Put hooks behind feature flag
2018-10-29 11:26:53 -07:00
Andrew Clark and Andrew Clark
7bee9fbdd4
Initial hooks implementation
...
Includes:
- useState
- useContext
- useEffect
- useRef
- useReducer
- useCallback
- useMemo
- useAPI
2018-10-29 11:26:53 -07:00
Rauno Freiberg and Andrew Clark
37c7fe0a5f
Update createRoot warning message based on enableStableConcurrentModeAPIs ( #14017 )
2018-10-29 11:25:24 -07:00
Jeffrey Zhang and Nathan Hunzaker
ae4f3f07e5
Remove extraneous CSS selector ( #13996 )
2018-10-27 10:01:25 -07:00
Joseph and Nathan Hunzaker
95f98a1873
fix typo ( #13955 )
2018-10-27 09:59:00 -07:00
Patrick and Nathan Hunzaker
e217f2f1ac
Updated comment for getEventModifierState ( #13918 )
2018-10-27 09:52:01 -07:00
Brian Vaughn and GitHub
275e76e83b
Enable stable concurrent APIs flag for 16.7 alpha ( #13928 )
...
* Add enableStableConcurrentModeAPIs feature flag
* Conditionally name concurrent API based on enableStableConcurrentModeAPIs flag
2018-10-24 13:45:07 -07:00
Dan Abramov and GitHub
b5539ad628
It's Concurrent
2018-10-23 19:26:00 -07:00
Dan Abramov
0cc50b675a
Fix scheduler fixture
2018-10-23 16:35:07 -07:00
Dan Abramov
8b97a9c36f
Update bundle sizes for 16.6.0 release
v16.6.0
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
Dan Abramov
6c29eabf78
Updating package versions for release 16.6.0
2018-10-23 16:23:41 -07:00
Dan Abramov
d520b358d6
Revert all package versions to 16.5.2 state
...
Our release script is getting really confused so I'm resetting to last working state.
2018-10-23 16:18:28 -07:00