-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Warn when second callback is passed to setState/dispatch in Hooks #14625
Conversation
@@ -782,6 +782,15 @@ function dispatchAction<S, A>( | |||
'an infinite loop.', | |||
); | |||
|
|||
if (__DEV__) { | |||
warning( | |||
arguments.length <= 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could've been === 3 but I figured I don't want to punish users for our bugs.
ReactDOM: size: 0.0%, gzip: -0.0% Details of bundled changes.Comparing: d17d0b9...faa7bc2 react-dom
react-art
react-native-renderer
react-test-renderer
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It's supported in classes and not in Hooks. People try to pass it and wonder why it doesn't work. Now we warn for that. This also lets us add it (or something else) later as a second argument.