-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix no-unused-prop-types setState updater #1507
Conversation
'class MyComponent extends React.Component {', | ||
' onFoo() {', | ||
' this.setState((prevState, props) => {', | ||
' props.doSomething();', |
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.
does this work independent of what "props" is called?
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.
Not yet, working a better version that will handle more cases. This code doesn't handle destructuring or anything like that.
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.
I think it's important that it handles that from the get-go.
Does this case work with the prop-types rule? If not: the code is really similar and it should be possible to apply the same logic there. |
Handle when props are used in the setState update callback Fix jsx-eslint#1506
bf498a2
to
c471d77
Compare
Should handle this case much better now. Added a test case for when the second argument to the setState updater is not named |
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.
Seems legit
What about the prop-types rule? Does it also need this functionality? |
Yes, I think it does. |
Handle when props are used in the setState update callback
Fix #1506