Implement the experimental Hooks proposal behind a feature flag #13968
Conversation
Details of bundled changes.Comparing: 5045763...5045763 scheduler
Generated by |
I'm so sorry to say this in this thread but I notice this:
Oh guys, the last time you do this is the Suspense. Great work ! -------- I will remove this comment if it causes spam |
|
Wait wait I want to approve it, too! |
Hold up, but I also want to approve it |
Great stuff |
wow, great idea |
|
]); | ||
}); | ||
|
||
it('flushes passive effects even if siblings schedule a new root', () => { |
philipp-spiess
Oct 26, 2018
•
Member
I wonder how you came up with all of those edge cases. 😉
I wonder how you came up with all of those edge cases.
gaearon
Oct 28, 2018
•
Member
Ran into bugs in the first implementation by trying it on the product code.
Ran into bugs in the first implementation by trying it on the product code.
false, | ||
'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + | ||
'removed in a future major release. Did you mean to call useContext(Context) instead?', | ||
); |
Jessidhia
Oct 27, 2018
Contributor
Interesting; this also means that you can't use the usual const { Provider, Consumer } = React.createContext()
pattern with hooks.
Interesting; this also means that you can't use the usual const { Provider, Consumer } = React.createContext()
pattern with hooks.
trueadm
Oct 27, 2018
Member
There’s no reason to use that pattern anymore with hooks.
There’s no reason to use that pattern anymore with hooks.
gaearon
Oct 28, 2018
Member
It's plausible one of returned values would be a Hook itself in the future.
It's plausible one of returned values would be a Hook itself in the future.
seems okay |
Includes: - useState - useContext - useEffect - useRef - useReducer - useCallback - useMemo - useAPI
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).
Co-authored-by: Alex Taylor <alexmckenley@gmail.com> Co-authored-by: Andrew Clark <acdlite@fb.com>
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.
Previously, flushPassiveEffects (called by scheduling work) would overwrite rootWithPendingPassiveEffects before we had a chance to schedule the work.
wow, writing code is hard
Hooks let you use all React features (such as state and lifecycle) without writing a class.
We have presented the Hooks proposal at React Conf 2018. This pull request implements all proposed built-in Hooks behind a feature flag, both for the client and the server renderer.
This is a very early time for Hooks and this proposal is experimental. We're merging it into master now so we can iterate on it. It is turned on only in the 16.7 alpha release so that you can try it and provide your feedback.
We have been using this code for a month in production so while the APIs are not stable, we don't expect the implementation to contain major bugs.
Please keep the feedback and discussion contained in the Hooks RFC (and not in this PR) so that everyone can discuss it in a single place without checking multiple GitHub threads.