-
Notifications
You must be signed in to change notification settings - Fork 46.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: warn when returning different hooks on subsequent renders #14585
RFC: warn when returning different hooks on subsequent renders #14585
Conversation
like it says. adds a field to Hook to track effect 'type', and compares when cloning subsequently.
Maybe we could use react-debug-tools to print a warning that shows the expected the hook structure versus the actual one cc @bvaughn |
ReactDOM: size: 0.0%, gzip: 0.0% Details of bundled changes.Comparing: 3fbebb2...3ad6523 react-dom
react-art
react-native-renderer
react-test-renderer
react-reconciler
Generated by 🚫 dangerJS |
I’m thinking the message should emphasize the name of the top most hook that doesn’t match. Otherwise it’s not very helpful for custom hooks. |
packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js
Outdated
Show resolved
Hide resolved
I have an odd bug in my test, where even though I'm matching the warning message exactly, |
- numbered enum for hook types - s/hookType/_debugType - better dce
thanks for reviewing my PR on a sunday y'all :) |
a couple that are missing
EDIT: done |
need to verify dce still works
Looks like there's some overlap here with #14594 for tracking the hook name/type in DEV |
@aweary hrmm yeah you're right. I'll refactor. thanks for the catch! |
^ like it says. adds a field to
Hook
to track hook 'type', and compares when cloning on further renders.started this PR/mvp to discuss how you folks would like this implemented?
I have run the tests (and added one!)