Skip to content
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

Enhance get derived state from props state warning - #12670 #13317

Conversation

flxwu
Copy link

@flxwu flxwu commented Aug 3, 2018

The current warning that getDerivedStateFromProps produces when called with state == null (intentional null or undefined/not declared) is a bit unclear, so this PR adapts this message for the developer to directly recognize that he didn't declare the Component's state before getDerivedStateFromProps.

Resolves: #12670.

The updated message is now:

Component state must be properly initialized when using getDerivedStateFromProps.

@gaearon
Copy link
Collaborator

gaearon commented Aug 3, 2018

Thanks. I ended up tweaking the message since people are often confused why we have it.

@gaearon gaearon force-pushed the bugfix/enhance-getDerivedStateFromProps-state-warning branch from 39f9b26 to 0b54ed3 Compare August 3, 2018 14:38
@flxwu
Copy link
Author

flxwu commented Aug 3, 2018

yeah, right 👍 @gaearon although I don't get why you would intentionally set state to null 😅

@gaearon gaearon merged commit b179bae into facebook:master Aug 3, 2018
@flxwu flxwu deleted the bugfix/enhance-getDerivedStateFromProps-state-warning branch August 3, 2018 15:55
@gaearon gaearon mentioned this pull request Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants