-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Calling setProps
on shallow wrapper results in componentDidUpdate
being called twice
#1862
Comments
setProps
on wrapperresults in componentDidUpdate
being called twicesetProps
on wrapper results in componentDidUpdate
being called twice
( It seems like the issue is that it's calling cWRP, queueing up a setState, rerendering with the props only, and calling cDU, and then rerendering with the new state, and then calling cDU again. I presume that React itself is batching up the updates so that this is working as expected - I don't believe we have proper batching support for React 16 just yet. (cc @koba04) |
What happens when you use |
@ljharb So currently, it's a no-op. If we support batching updates on |
Although that's a lot more work, I think it's probably worth it so that things are consistent between React and enzyme. |
setProps
on wrapper results in componentDidUpdate
being called twicesetProps
on shallow wrapper results in componentDidUpdate
being called twice
@ljharb thanks, |
I'll go ahead and look into this issue if a fix hasn't already been applied. |
@peanutenthusiast not much, but I'd love to add it (ideally separate from bug fixes) |
Was out of country for a month or so, but I've come up with a fix for the above test case -- @ljharb are there any other test cases that should be covered? I can send a PR tonight. |
Not that i know of; PR away! |
Awesome, thanks everyone! |
Describe the bug
Calling
setProps
on a shallow wrapper results incomponentDidUpdate
being called twice (instead of once).To Reproduce
Steps to reproduce the behavior:
Run the test:
Expected behavior
componentDidUpdate
should only be called once.Desktop (please complete the following information):
Smartphone (please complete the following information):
n/a
The text was updated successfully, but these errors were encountered: