Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
shallow renderer: wrong initial state passed to getDerivedStateFromProps #15075
Demonstrated in airbnb/enzyme#2027 - when gDSFP returns a state change, cDU does not seem to be called by the shallow renderer. I'm not sure how to make a simple test case; but the identical enzyme tests pass for
referenced this issue
Mar 9, 2019
I'm actually seeing two issues here:
https://codesandbox.io/s/m7nn4v428 shows the behavior of React itself:
https://codesandbox.io/s/mqm4o7m7nx shows the behavior of the shallow renderer:
(I'm not sure where to start with a PR for these fixes; if someone can help by either implementing the fix, or sharing a branch with failing tests so i can build a fix on top of that, or a direct link to where the tests and fix would go, that would be great)
Here's an example of a recent gDSFP fix, it shows where to change the code and where the tests go.
Looking at it again — this works as intended.
Shallow renderer has never fired
There is a bigger discussion to have about the future status of shallow renderer in and its design, but the reported issue is not a bug.
changed the title
shallow renderer: when getDerivedStateFromProps changes state, componentDidUpdate is not called.
Mar 19, 2019
Hmm - now I can't reproduce it even on my original sandboxes :-/ I see the same minor discrepancy as you when I comment out the state assignment in the
I'm going to close this - I'll comment here, or file a new issue, if I see anything else.