-
-
Notifications
You must be signed in to change notification settings - Fork 2k
ShallowRenderer.simulate supports batched updates #342
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
ShallowRenderer.simulate supports batched updates #342
Conversation
|
Interesting. So you are planning on using this to ensure that the batching behavior of setState is accurately depicted in #318? |
src/react-compat.js
Outdated
| }; | ||
| } | ||
|
|
||
| const batchedUpdates = require('react/lib/ReactUpdates').batchedUpdates; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might become an issue due to facebook/react#6460. depending on which way they go. Hopefully this might help sway them away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'll likely have to be reactive when it comes to facebook/react#6460. We should definitely try to work with the React team if they want to support libraries like enzyme in some capacity.
Also @koba04 can you put this require up at the top with the main const React = require('react') statement, since this is not a version dependant import at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aweary I've updated it!
270a544 to
066aefd
Compare
|
Since there is a public API for What do you think @blainekasten @lelandrichardson @koba04? |
|
@aweary I've updated this PR to use public APIs for batchedUpdates! It's not complicated for me 😄 |
|
LGTM |
1 similar comment
|
LGTM |
|
I'll have to find out whether react batches updates for all handlers triggered by an event for #368, if anyone knows let me know |
|
@nfcampos a cursory glance suggest that they do but we'll have to investigate that further to verify. |
|
@ljharb @lelandrichardson it doesn't seem like the LGTM check seems to be working? |
|
LGTM |
|
@aweary turns out that the issue is lgtmco/lgtm#19 - i'll update our MAINTAINERS file in the meantime. |
dbecc1b to
1c866e1
Compare
|
rebased |
|
@koba04 can you rebase please? I think we can merge this afterwards. |
1c866e1 to
bd5249c
Compare
|
@aweary rebased! |
|
Thanks @koba04! |
|
Thanks for your help 🎉 |
This PR is for
ShallowWrapper.simulate()supports batched updates usingReactUpdates.batchedUpdates.React.addons.TestUtils.Simulate.{eventName}is supporting batched updates.ref. https://jsfiddle.net/koba04/6Lchbest/
ReactUpdates.batchedUpdatesis exported asReactDOM. unstable_batchedUpdatesfrom React v0.14. In React v0.13, it is exported asReact.addons.batchedUpdates.It might be better I use the exported interface.
But I guess it makes your configurations complex than using
ReactUpdates.batchedUpdatesdirectly.FYI: This batched updates feature is required #318.
Thanks.