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
shallow renderer: wrong initial state passed to getDerivedStateFromProps #15075
Comments
Could you please setup a sandbox? |
Happy to take a bugfix if you think it's a bug. (See existing shallow renderer tests) |
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. |
I'll look into this. |
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. |
@gaearon note as well the discrepancy in the first call to gDSFP - should i file a new issue, or can this be reopened? |
Oops, missed that. Thanks. |
Hmm, I can't repro with https://codesandbox.io/s/mqm4o7m7nx: I don't see undefined. |
Is it only if you omit |
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. |
Demonstrated in enzymejs/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
mount
(ie, when using React itself) but fail forshallow
(when using the shallow renderer). enzyme doesn't have any logic for calling or interacting withgetDerivedStateFromProps
, so I suspect it's not an issue with enzyme (but it might be!)The text was updated successfully, but these errors were encountered: