Commit Graph
10435 Commits
Author SHA1 Message Date
Brian VaughnandGitHub 7b3ded2e99 Fix react-cache UMD build (#14047) 2018-10-31 11:16:03 -07:00
Sophie AlpertandGitHub fd0b66bf6b 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 AlpertandGitHub 5495caa765 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 ClarkandGitHub dce80d670c [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 ClarkandGitHub 5d25f3db78 [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 d8641059f9 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 c104739bc7 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 3ff962f6e5 Prettier 2018-10-29 12:29:41 -07:00
Andrew Clark 5ff29a5ede Swap order of function member in hook union types 2018-10-29 11:42:41 -07:00
Caleb MeredithandAndrew Clark 2789879dd8 Add ESLint rule for React Hooks 2018-10-29 11:26:54 -07:00
Andrew Clark fe2c9746f3 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 ClarkandAndrew Clark 173c5579a8 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 AlpertandAndrew Clark a460f17b3b 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 TaylorandAndrew Clark 1c667ce932 Add readContext to ReactPartialRendererHooks 2018-10-29 11:26:54 -07:00
Dan AbramovandAndrew Clark 3f7deab1e1 Warn about useContext(Consumer|Provider) 2018-10-29 11:26:54 -07:00
Dan AbramovandAndrew Clark 3259d6bd91 Test useContext in pure, forwardRef, and PureComponent 2018-10-29 11:26:54 -07:00
Sophie AlpertandAndrew Clark 1d6ef18746 Make effects actually work with memo
Bug fix.
2018-10-29 11:26:54 -07:00
Sophie AlpertandAndrew Clark 8f8cb8a722 The Lost Effect, chapter 3
wow, writing code is hard
2018-10-29 11:26:54 -07:00
Sophie AlpertandAndrew Clark 15e8ff1be9 memo supports Hooks 2018-10-29 11:26:53 -07:00
Sophie AlpertandAndrew Clark 40350eaba4 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ĂĄgeandAndrew Clark 4191797272 "functional component" -> "function component" in hooks error messages 2018-10-29 11:26:53 -07:00
Sophie AlpertandAndrew Clark 8329c5fb6c Warn for Hook set-state on unmounted component 2018-10-29 11:26:53 -07:00
Sophie AlpertandAndrew Clark 9e8a4d3444 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
d09090c296 Add support for hooks to ReactDOMServer
Co-authored-by: Alex Taylor <[email protected]>
Co-authored-by: Andrew Clark <[email protected]>
2018-10-29 11:26:53 -07:00
Andrew ClarkandAndrew Clark d0f81d1130 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 ClarkandAndrew Clark 535b7cf764 Put hooks behind feature flag 2018-10-29 11:26:53 -07:00
Andrew ClarkandAndrew Clark 0282bbd085 Initial hooks implementation
Includes:
- useState
- useContext
- useEffect
- useRef
- useReducer
- useCallback
- useMemo
- useAPI
2018-10-29 11:26:53 -07:00
Rauno FreibergandAndrew Clark 511df91520 Update createRoot warning message based on enableStableConcurrentModeAPIs (#14017) 2018-10-29 11:25:24 -07:00
Jeffrey ZhangandNathan Hunzaker d7240eff9a Remove extraneous CSS selector (#13996) 2018-10-27 10:01:25 -07:00
JosephandNathan Hunzaker 77d07165e9 fix typo (#13955) 2018-10-27 09:59:00 -07:00
PatrickandNathan Hunzaker a109d24654 Updated comment for getEventModifierState (#13918) 2018-10-27 09:52:01 -07:00
Brian VaughnandGitHub 67712b3a66 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 AbramovandGitHub a6e9861d7b It's Concurrent 2018-10-23 19:26:00 -07:00
Dan Abramov 1e4178d7e6 Fix scheduler fixture 2018-10-23 16:35:07 -07:00
Dan Abramov 315b223cf0 Update bundle sizes for 16.6.0 release 2018-10-23 16:29:35 -07:00
Dan Abramov 78bc36ff80 Update error codes for 16.6.0 release 2018-10-23 16:29:35 -07:00
Dan Abramov 4985ccf91b Updating package versions for release 16.6.0 2018-10-23 16:23:41 -07:00
Dan Abramov 3762c14b3f 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
Dan Abramov 3594abff3b Bump versions to beta.0 2018-10-23 16:01:57 -07:00
Dan Abramov de98759150 Revert "Revert "Updating dependencies for react-noop-renderer""
This reverts commit 4088ac8269.
2018-10-23 15:59:36 -07:00
Brian Vaughn 4088ac8269 Revert "Updating dependencies for react-noop-renderer"
This reverts commit 9ea09f05ab.
2018-10-23 15:36:31 -07:00
Brian Vaughn 6f847464d5 Prettier 2018-10-23 15:06:58 -07:00
Brian VaughnandGitHub 27c7c98684 Add skipCI flag to release script (#13933) 2018-10-23 15:05:14 -07:00
Dan AbramovandGitHub d1142995ee Fix Suspense fixture (#13932) 2018-10-23 18:03:22 -04:00
Andrew ClarkandGitHub fb6bcae39f [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
Andrew ClarkandBrian Vaughn c66ae0d68d Revert accidentally committed existence check (#13931) 2018-10-23 14:27:04 -07:00
Brian VaughnandGitHub 827c4d5e7c Removed react-cache from the bundle list for now (#13930)
* Removed react-cache from the bundle list for now

* Re-add react-cache bundle, but mark as private to avoid NPM publishing
2018-10-23 13:55:52 -07:00
Brian VaughnandGitHub 5871848dff 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
Dan AbramovandGitHub a0660170b3 Fix Markdown 2018-10-23 12:16:13 -07:00
Dan AbramovandGitHub ab70dd863a Tweak changelog credits 2018-10-23 12:15:57 -07:00