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 the wrong renderer's act() should warn #15756

Merged

Conversation

threepointone
Copy link
Contributor

@threepointone threepointone commented May 28, 2019

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
Copy link

sizebot commented May 28, 2019

ReactDOM: size: 0.0%, gzip: 0.0%

Details of bundled changes.

Comparing: 401065f...c0dc398

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.1% +0.2% 851.82 KB 853.07 KB 193.93 KB 194.31 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 105.48 KB 105.48 KB 34.28 KB 34.28 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 108.63 KB 108.63 KB 35.29 KB 35.3 KB UMD_PROFILING
react-dom.development.js +0.1% +0.2% 846.14 KB 847.39 KB 192.37 KB 192.74 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 105.47 KB 105.48 KB 33.68 KB 33.68 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 108.81 KB 108.81 KB 34.55 KB 34.55 KB NODE_PROFILING
ReactDOM-dev.js +0.2% +0.2% 871.69 KB 873.1 KB 194.02 KB 194.39 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 355.19 KB 355.2 KB 65.72 KB 65.72 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 360.38 KB 360.39 KB 66.66 KB 66.66 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js +0.1% +0.2% 852.16 KB 853.42 KB 194.08 KB 194.45 KB UMD_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 105.49 KB 105.5 KB 34.29 KB 34.29 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 108.65 KB 108.65 KB 35.3 KB 35.3 KB UMD_PROFILING
react-dom-unstable-fire.development.js +0.1% +0.2% 846.48 KB 847.73 KB 192.51 KB 192.88 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 105.49 KB 105.49 KB 33.69 KB 33.69 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 108.82 KB 108.82 KB 34.56 KB 34.56 KB NODE_PROFILING
ReactFire-dev.js +0.2% +0.2% 870.9 KB 872.31 KB 193.98 KB 194.35 KB FB_WWW_DEV
ReactFire-prod.js 0.0% 0.0% 343.13 KB 343.14 KB 63.28 KB 63.28 KB FB_WWW_PROD
ReactFire-profiling.js 0.0% 0.0% 348.33 KB 348.34 KB 64.21 KB 64.22 KB FB_WWW_PROFILING
react-dom-test-utils.development.js +0.4% +0.2% 57.24 KB 57.47 KB 15.75 KB 15.78 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.81 KB 10.81 KB 3.97 KB 3.97 KB UMD_PROD
react-dom-test-utils.development.js +0.4% +0.2% 55.58 KB 55.81 KB 15.43 KB 15.46 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.56 KB 10.56 KB 3.92 KB 3.91 KB NODE_PROD
ReactTestUtils-dev.js +0.4% +0.2% 53.03 KB 53.26 KB 14.28 KB 14.31 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.76 KB 60.76 KB 15.85 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.69 KB 10.69 KB 3.67 KB 3.67 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.43 KB 60.43 KB 15.72 KB 15.72 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.43 KB 10.43 KB 3.56 KB 3.57 KB NODE_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 19.12 KB 19.12 KB 7.22 KB 7.22 KB NODE_PROD
ReactDOMServer-dev.js 0.0% -0.0% 135.44 KB 135.44 KB 34.79 KB 34.79 KB FB_WWW_DEV
ReactDOMServer-prod.js 0.0% -0.0% 47.93 KB 47.93 KB 11.03 KB 11.03 KB FB_WWW_PROD
react-dom-server.node.production.min.js 0.0% 0.0% 19.98 KB 19.98 KB 7.52 KB 7.53 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.64 KB 3.64 KB 1.49 KB 1.49 KB NODE_DEV
react-dom-unstable-fizz.node.development.js 0.0% -0.1% 3.88 KB 3.88 KB 1.51 KB 1.51 KB NODE_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.2% +0.3% 585.03 KB 586.26 KB 127.87 KB 128.24 KB UMD_DEV
react-art.development.js +0.2% +0.3% 515.94 KB 517.17 KB 110.39 KB 110.75 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 61.91 KB 61.91 KB 19.12 KB 19.12 KB NODE_PROD
ReactART-dev.js +0.3% +0.3% 526.33 KB 527.72 KB 109.69 KB 110.05 KB FB_WWW_DEV
ReactART-prod.js 0.0% 0.0% 201.85 KB 201.85 KB 34.38 KB 34.38 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.2% +0.3% 660.4 KB 661.79 KB 140.22 KB 140.58 KB RN_FB_DEV
ReactNativeRenderer-prod.js 0.0% -0.0% 251.36 KB 251.36 KB 43.48 KB 43.48 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.2% +0.3% 660.32 KB 661.7 KB 140.2 KB 140.55 KB RN_OSS_DEV
ReactNativeRenderer-prod.js 0.0% -0.0% 251.37 KB 251.37 KB 43.48 KB 43.48 KB RN_OSS_PROD
ReactFabric-dev.js +0.2% +0.3% 649.18 KB 650.57 KB 137.6 KB 137.95 KB RN_FB_DEV
ReactFabric-profiling.js 0.0% 0.0% 252.25 KB 252.25 KB 43.89 KB 43.89 KB RN_FB_PROFILING
ReactFabric-dev.js +0.2% +0.3% 649.09 KB 650.47 KB 137.57 KB 137.92 KB RN_OSS_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +0.3% +0.3% 529.63 KB 530.97 KB 113.3 KB 113.68 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 63.26 KB 63.26 KB 19.54 KB 19.55 KB UMD_PROD
react-test-renderer.development.js +0.3% +0.3% 525.17 KB 526.51 KB 112.19 KB 112.56 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 62.94 KB 62.94 KB 19.33 KB 19.33 KB NODE_PROD
ReactTestRenderer-dev.js +0.3% +0.3% 537.64 KB 539.14 KB 112.24 KB 112.61 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 41.84 KB 41.84 KB 10.82 KB 10.82 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 11.6 KB 11.6 KB 3.55 KB 3.55 KB UMD_PROD
react-test-renderer-shallow.production.min.js 0.0% 🔺+0.1% 11.74 KB 11.74 KB 3.67 KB 3.67 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.2% +0.3% 513.49 KB 514.77 KB 108.86 KB 109.24 KB NODE_DEV
react-reconciler.production.min.js 0.0% 🔺+0.1% 63.01 KB 63.03 KB 18.93 KB 18.95 KB NODE_PROD
react-reconciler-persistent.development.js +0.3% +0.4% 511.17 KB 512.44 KB 107.86 KB 108.23 KB NODE_DEV
react-reconciler-persistent.production.min.js 0.0% 🔺+0.1% 63.02 KB 63.04 KB 18.93 KB 18.95 KB NODE_PROD
react-reconciler-reflection.production.min.js 0.0% -0.2% 2.51 KB 2.51 KB 1.12 KB 1.11 KB NODE_PROD

Generated by 🚫 dangerJS

@threepointone
Copy link
Contributor Author

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
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
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
Contributor Author

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants