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

Fix shallow renderer set instance state after gDSFP before calling sCU #14613

Merged

Conversation

chenesan
Copy link
Contributor

This PR fixes #14607 which is related to enzymejs/enzyme#1970 . Before this the shallow renderer will update instance state before shouldComponentUpdate if getDeriveStateFromProps return new partial state, make the passed nextState and old this.state the same in shouldComponentUpdate, which is different behavior with real rendering with ReactDOM.render (see the tests).

@gaearon
Copy link
Collaborator

gaearon commented Jan 18, 2019

I think _updateStateFromStaticLifecycle might have been creating more confusion than what it's worth due to timing issues of what writes when. So I unwound it. I think this makes sense.

Copy link
Collaborator

@gaearon gaearon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked Enzyme tests and they pass. Seems good. Thanks.

@gaearon gaearon merged commit 4f33288 into facebook:master Jan 18, 2019
jetoneza pushed a commit to jetoneza/react that referenced this pull request Jan 23, 2019
facebook#14613)

* Fix shallow renderer set instance state after gDSFP before calling sCU

* Update ReactShallowRenderer.js

* Unwind abstraction

* Fewer names
n8schloss pushed a commit to n8schloss/react that referenced this pull request Jan 31, 2019
facebook#14613)

* Fix shallow renderer set instance state after gDSFP before calling sCU

* Update ReactShallowRenderer.js

* Unwind abstraction

* Fewer names
This was referenced Sep 20, 2019
NMinhNguyen referenced this pull request in enzymejs/react-shallow-renderer Jan 29, 2020
…U (#14613)

* Fix shallow renderer set instance state after gDSFP before calling sCU

* Update ReactShallowRenderer.js

* Unwind abstraction

* Fewer names
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.

Bug: in shallow renderer this.state in shouldComponentUpdate will be updated by getDeriveStateFromProps
3 participants