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

Using TestRenderer.act() should not silence the ReactDOM warning #15319

Closed
gaearon opened this issue Apr 4, 2019 · 1 comment
Closed

Using TestRenderer.act() should not silence the ReactDOM warning #15319

gaearon opened this issue Apr 4, 2019 · 1 comment

Comments

@gaearon
Copy link
Collaborator

gaearon commented Apr 4, 2019

ReactTestRenderer.act() only works for react-test-renderer.
ReactTestUtils.act() only works for react-dom.

Unfortunately due to poor naming, people confuse those two things.

We need to:

  • Make sure ReactTestRenderer.act() around react-dom updates doesn't silence the warning, and vice versa. (Currently, it does — but you can fix it by using an empty object that's unique per renderer instead of a true value.)

  • Add a special warning message when a different renderer is "acting" updates. That warning message should suggest that you're supposed to use act() corresponding to the renderer you're using, e.g. react-dom/test-utils for react-dom.

This should fix most cases where people wrap updates in the wrong act.

threepointone pushed a commit to threepointone/react that referenced this issue Apr 12, 2019
via facebook#15319
This solves 2 specific problems -
- using the 'wrong' act() doesn't silence the warning
- using the wrong act logs a warning

It does this by using an empty object on the reconciler as the identity of ReactShouldWarnActingUpdates.current. We also add this check when calling createContainer() to catch the common failure of this happening right in the beginning.
threepointone pushed a commit to threepointone/react that referenced this issue Apr 12, 2019
via facebook#15319
This solves 2 specific problems -
- using the 'wrong' act() doesn't silence the warning
- using the wrong act logs a warning

It does this by using an empty object on the reconciler as the identity of ReactShouldWarnActingUpdates.current. We also add this check when calling createContainer() to catch the common failure of this happening right in the beginning.
threepointone pushed a commit to threepointone/react that referenced this issue Apr 15, 2019
via facebook#15319
This solves 2 specific problems -
- using the 'wrong' act() doesn't silence the warning
- using the wrong act logs a warning

It does this by using an empty object on the reconciler as the identity of ReactShouldWarnActingUpdates.current. We also add this check when calling createContainer() to catch the common failure of this happening right in the beginning.

make a proper fixture for act()

made fixtures/act for act(). specifically, this lets us tests how act behaves when you use the wrong act() for the wrong renderer. also mvoes dom/../act-dom.html to this fixture.

cleanup fixtures/dom/.gitignore

verify that it 'works' with art+dom

verify that it 'works' with art+test

augh prettier

tweak warning messages
@threepointone
Copy link
Contributor

fixed in #15756, closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants