Commit Graph

10432 Commits

Author SHA1 Message Date
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
Alex Taylor 9f34eb79a3 Add readContext to ReactPartialRendererHooks 2018-10-29 11:26:54 -07:00
Dan Abramov f7cb9d2b22 Warn about useContext(Consumer|Provider) 2018-10-29 11:26:54 -07:00
Dan Abramov 63cc7d2b31 Test useContext in pure, forwardRef, and PureComponent 2018-10-29 11:26:54 -07:00
Sophie Alpert 3a7c6da8d4 Make effects actually work with memo
Bug fix.
2018-10-29 11:26:54 -07:00
Sophie Alpert 75a1c2e72a The Lost Effect, chapter 3
wow, writing code is hard
2018-10-29 11:26:54 -07:00
Sophie Alpert 55a4b1f377 memo supports Hooks 2018-10-29 11:26:53 -07:00
Sophie Alpert 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 b772e0e26b "functional component" -> "function component" in hooks error messages 2018-10-29 11:26:53 -07:00
Sophie Alpert 9e9e3970e4 Warn for Hook set-state on unmounted component 2018-10-29 11:26:53 -07:00
Sophie Alpert 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
Alex Taylor 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 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 105f2de545 Put hooks behind feature flag 2018-10-29 11:26:53 -07:00
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 37c7fe0a5f Update createRoot warning message based on enableStableConcurrentModeAPIs (#14017) 2018-10-29 11:25:24 -07:00
Jeffrey Zhang ae4f3f07e5 Remove extraneous CSS selector (#13996) 2018-10-27 10:01:25 -07:00
Joseph 95f98a1873 fix typo (#13955) 2018-10-27 09:59:00 -07:00
Patrick e217f2f1ac Updated comment for getEventModifierState (#13918) 2018-10-27 09:52:01 -07:00
Brian Vaughn 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 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
Dan Abramov 8f1ec7649e Bump versions to beta.0 2018-10-23 16:01:57 -07:00
Dan Abramov 5055a83fa4 Revert "Revert "Updating dependencies for react-noop-renderer""
This reverts commit 3e8b4a5b8b.
2018-10-23 15:59:36 -07:00
Brian Vaughn 3e8b4a5b8b Revert "Updating dependencies for react-noop-renderer"
This reverts commit 1a57dc6689.
2018-10-23 15:36:31 -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
Dan Abramov d42ed60026 Fix Suspense fixture (#13932) 2018-10-23 18:03:22 -04: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
Andrew Clark fefa1269e2 Revert accidentally committed existence check (#13931) 2018-10-23 14:27:04 -07:00
Brian Vaughn 80a0c05ce3 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 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
Dan Abramov 508b5fba0e Fix Markdown 2018-10-23 12:16:13 -07:00
Dan Abramov c285ea2700 Tweak changelog credits 2018-10-23 12:15:57 -07:00
Dan Abramov eac092ecac Add 16.6.0 changelog (#13927)
* Add 16.6.0 changelog

* Update CHANGELOG.md
2018-10-23 15:08:08 -04:00
Andrew Clark cbbc2b6c4d [Synchronous Suspense] Suspending a class outside concurrent mode (#13926)
* [Synchronous Suspense] Suspending a class outside concurrent mode

When a class component suspends during mount outside concurrent mode,
change the tag so it's not mistaken for a completed component. For
example, we should not call componentWillUnmount if it is deleted.

* PR nits
2018-10-23 11:36:56 -07:00
Sebastian Markbåge 4947fcd762 Fix lint (#13923) 2018-10-22 22:47:39 -07:00