Skip to content

using the wrong renderer's act() should warn - #15756

Merged
threepointone merged 6 commits into
react:masterfrom
threepointone:wrong-renderer-act-warning
May 29, 2019
Merged

using the wrong renderer's act() should warn#15756
threepointone merged 6 commits into
react:masterfrom
threepointone:wrong-renderer-act-warning

Conversation

@threepointone

@threepointonethreepointone commented May 28, 2019

Copy link
Copy Markdown
Contributor

via #15319

(redid #15399, removed the changes that didn't even belong in it.)

So tl;dr this PR -

  • uses a renderer specific object as the value of ReactCurrentActingRendererSigil.current
  • checks this value on 'updateContainer`
  • checks this value when setting a state hook's value
  • adds a fixture folder for act() (which is run on CI)

This solves 2 specific problems -

  • using the wrong act() shouldn't silence the 'missing act' warning
  • using the wrong act() logs a warning tha you're, er, using the wrong act()

(Please see #15399 for the long spiel on the mechanics for this.)

…dates
like it says. it uses a real object as the sigil (instead of just a boolean). specifically, it uses a renderer's flushPassiveEffects as the sigil. We also run tests for this separate from our main suite (which doesn't allow loading multiple renderers in a suite), but makes sure to run this in CI as well.
@sizebot

sizebot commented May 28, 2019

Copy link
Copy Markdown

ReactDOM: size: 0.0%, gzip: 0.0%

Details of bundled changes.

Comparing: 401065f...c0dc398

react-dom

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
react-dom.development.js+0.1%+0.2%851.82 KB853.07 KB193.93 KB194.31 KBUMD_DEV
react-dom.production.min.js0.0%0.0%105.48 KB105.48 KB34.28 KB34.28 KBUMD_PROD
react-dom.profiling.min.js0.0%0.0%108.63 KB108.63 KB35.29 KB35.3 KBUMD_PROFILING
react-dom.development.js+0.1%+0.2%846.14 KB847.39 KB192.37 KB192.74 KBNODE_DEV
react-dom.production.min.js0.0%0.0%105.47 KB105.48 KB33.68 KB33.68 KBNODE_PROD
react-dom.profiling.min.js0.0%0.0%108.81 KB108.81 KB34.55 KB34.55 KBNODE_PROFILING
ReactDOM-dev.js+0.2%+0.2%871.69 KB873.1 KB194.02 KB194.39 KBFB_WWW_DEV
ReactDOM-prod.js0.0%0.0%355.19 KB355.2 KB65.72 KB65.72 KBFB_WWW_PROD
ReactDOM-profiling.js0.0%0.0%360.38 KB360.39 KB66.66 KB66.66 KBFB_WWW_PROFILING
react-dom-unstable-fire.development.js+0.1%+0.2%852.16 KB853.42 KB194.08 KB194.45 KBUMD_DEV
react-dom-unstable-fire.production.min.js0.0%0.0%105.49 KB105.5 KB34.29 KB34.29 KBUMD_PROD
react-dom-unstable-fire.profiling.min.js0.0%0.0%108.65 KB108.65 KB35.3 KB35.3 KBUMD_PROFILING
react-dom-unstable-fire.development.js+0.1%+0.2%846.48 KB847.73 KB192.51 KB192.88 KBNODE_DEV
react-dom-unstable-fire.production.min.js0.0%0.0%105.49 KB105.49 KB33.69 KB33.69 KBNODE_PROD
react-dom-unstable-fire.profiling.min.js0.0%0.0%108.82 KB108.82 KB34.56 KB34.56 KBNODE_PROFILING
ReactFire-dev.js+0.2%+0.2%870.9 KB872.31 KB193.98 KB194.35 KBFB_WWW_DEV
ReactFire-prod.js0.0%0.0%343.13 KB343.14 KB63.28 KB63.28 KBFB_WWW_PROD
ReactFire-profiling.js0.0%0.0%348.33 KB348.34 KB64.21 KB64.22 KBFB_WWW_PROFILING
react-dom-test-utils.development.js+0.4%+0.2%57.24 KB57.47 KB15.75 KB15.78 KBUMD_DEV
react-dom-test-utils.production.min.js0.0%-0.0%10.81 KB10.81 KB3.97 KB3.97 KBUMD_PROD
react-dom-test-utils.development.js+0.4%+0.2%55.58 KB55.81 KB15.43 KB15.46 KBNODE_DEV
react-dom-test-utils.production.min.js0.0%-0.0%10.56 KB10.56 KB3.92 KB3.91 KBNODE_PROD
ReactTestUtils-dev.js+0.4%+0.2%53.03 KB53.26 KB14.28 KB14.31 KBFB_WWW_DEV
react-dom-unstable-native-dependencies.development.js0.0%-0.0%60.76 KB60.76 KB15.85 KB15.85 KBUMD_DEV
react-dom-unstable-native-dependencies.production.min.js0.0%-0.0%10.69 KB10.69 KB3.67 KB3.67 KBUMD_PROD
react-dom-unstable-native-dependencies.development.js0.0%-0.0%60.43 KB60.43 KB15.72 KB15.72 KBNODE_DEV
react-dom-unstable-native-dependencies.production.min.js0.0%0.0%10.43 KB10.43 KB3.56 KB3.57 KBNODE_PROD
react-dom-server.browser.production.min.js0.0%0.0%19.12 KB19.12 KB7.22 KB7.22 KBNODE_PROD
ReactDOMServer-dev.js0.0%-0.0%135.44 KB135.44 KB34.79 KB34.79 KBFB_WWW_DEV
ReactDOMServer-prod.js0.0%-0.0%47.93 KB47.93 KB11.03 KB11.03 KBFB_WWW_PROD
react-dom-server.node.production.min.js0.0%0.0%19.98 KB19.98 KB7.52 KB7.53 KBNODE_PROD
react-dom-unstable-fizz.browser.development.js0.0%-0.1%3.64 KB3.64 KB1.49 KB1.49 KBNODE_DEV
react-dom-unstable-fizz.node.development.js0.0%-0.1%3.88 KB3.88 KB1.51 KB1.51 KBNODE_DEV

react-art

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
react-art.development.js+0.2%+0.3%585.03 KB586.26 KB127.87 KB128.24 KBUMD_DEV
react-art.development.js+0.2%+0.3%515.94 KB517.17 KB110.39 KB110.75 KBNODE_DEV
react-art.production.min.js0.0%0.0%61.91 KB61.91 KB19.12 KB19.12 KBNODE_PROD
ReactART-dev.js+0.3%+0.3%526.33 KB527.72 KB109.69 KB110.05 KBFB_WWW_DEV
ReactART-prod.js0.0%0.0%201.85 KB201.85 KB34.38 KB34.38 KBFB_WWW_PROD

react-native-renderer

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
ReactNativeRenderer-dev.js+0.2%+0.3%660.4 KB661.79 KB140.22 KB140.58 KBRN_FB_DEV
ReactNativeRenderer-prod.js0.0%-0.0%251.36 KB251.36 KB43.48 KB43.48 KBRN_FB_PROD
ReactNativeRenderer-dev.js+0.2%+0.3%660.32 KB661.7 KB140.2 KB140.55 KBRN_OSS_DEV
ReactNativeRenderer-prod.js0.0%-0.0%251.37 KB251.37 KB43.48 KB43.48 KBRN_OSS_PROD
ReactFabric-dev.js+0.2%+0.3%649.18 KB650.57 KB137.6 KB137.95 KBRN_FB_DEV
ReactFabric-profiling.js0.0%0.0%252.25 KB252.25 KB43.89 KB43.89 KBRN_FB_PROFILING
ReactFabric-dev.js+0.2%+0.3%649.09 KB650.47 KB137.57 KB137.92 KBRN_OSS_DEV

react-test-renderer

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
react-test-renderer.development.js+0.3%+0.3%529.63 KB530.97 KB113.3 KB113.68 KBUMD_DEV
react-test-renderer.production.min.js0.0%0.0%63.26 KB63.26 KB19.54 KB19.55 KBUMD_PROD
react-test-renderer.development.js+0.3%+0.3%525.17 KB526.51 KB112.19 KB112.56 KBNODE_DEV
react-test-renderer.production.min.js0.0%0.0%62.94 KB62.94 KB19.33 KB19.33 KBNODE_PROD
ReactTestRenderer-dev.js+0.3%+0.3%537.64 KB539.14 KB112.24 KB112.61 KBFB_WWW_DEV
react-test-renderer-shallow.development.js0.0%-0.0%41.84 KB41.84 KB10.82 KB10.82 KBUMD_DEV
react-test-renderer-shallow.production.min.js0.0%-0.0%11.6 KB11.6 KB3.55 KB3.55 KBUMD_PROD
react-test-renderer-shallow.production.min.js0.0%🔺+0.1%11.74 KB11.74 KB3.67 KB3.67 KBNODE_PROD

react-reconciler

FileFilesize DiffGzip DiffPrev SizeCurrent SizePrev GzipCurrent GzipENV
react-reconciler.development.js+0.2%+0.3%513.49 KB514.77 KB108.86 KB109.24 KBNODE_DEV
react-reconciler.production.min.js0.0%🔺+0.1%63.01 KB63.03 KB18.93 KB18.95 KBNODE_PROD
react-reconciler-persistent.development.js+0.3%+0.4%511.17 KB512.44 KB107.86 KB108.23 KBNODE_DEV
react-reconciler-persistent.production.min.js0.0%🔺+0.1%63.02 KB63.04 KB18.93 KB18.95 KBNODE_PROD
react-reconciler-reflection.production.min.js0.0%-0.2%2.51 KB2.51 KB1.12 KB1.11 KBNODE_PROD

Generated by 🚫 dangerJS

Comment threadpackage.json
Comment threadpackages/react-dom/src/test-utils/ReactTestUtilsAct.js
Comment threadpackages/react-dom/src/test-utils/ReactTestUtilsAct.js Outdated
@threepointone

Copy link
Copy Markdown
ContributorAuthor

updated the PR to use an explicit export (from ReactFiberWorkLoop) as the value of the sigil. I'll land this later tonight.

if (__DEV__) {
if (
ReactCurrentActingRendererSigil.current !== null &&
// use the function flushPassiveEffects directly as the sigil

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outdated comment

// so this comparison is expected here
ReactCurrentActingRendererSigil.current !== ReactActingRendererSigil
) {
// it looks like we're using the wrong matching act(), so log a warning

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment kinda repeats the warning?

"It looks like you're using the wrong act() around your test interactions.\n" +
'Be sure to use the matching version of act() corresponding to your renderer:\n\n' +
'// for react-dom:\n' +
"import {act} from 'react-test-utils';\n" +

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no such package either 🤦‍♂️

This was referenced Mar 10, 2020
mrizwanashiq pushed a commit to mrizwanashiq/react that referenced this pull request Jun 25, 2026
* warn when using the wrong renderer's act around another renderer's updates
like it says. it uses a real object as the sigil (instead of just a boolean). specifically, it uses a renderer's flushPassiveEffects as the sigil. We also run tests for this separate from our main suite (which doesn't allow loading multiple renderers in a suite), but makes sure to run this in CI as well.
* unneeded (and wrong) comment
* run the dom fixture on CI
* update the sigil only in __DEV__
* remove the obnoxious comment
* use an explicit export for the sigil
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@threepointone@sizebot@gaearon@acdlite@facebook-github-bot