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

allow nested act()s from different renderers #16039

Merged
merged 2 commits into from Jul 2, 2019

Conversation

threepointone
Copy link
Contributor

(an alternative to #15816)

There are usecases where multiple renderers need to operate inside a single act() scope.

  • ReactDOM.render being used inside another component tree. The parent component will be rendered using ReactTestRenderer.create for a snapshot test or something.
  • a ReactDOM instance interacting with a ReactTestRenderer instance (like for the new devtools)

This PR changes the way the acting sigils operate to allow for this. It keeps 2 booleans, one attached to React, one attached to the renderer. act() changes these values, and the workloop reads them to decide which warning to trigger.

(I also renamed shouldWarnUnactedUpdates to warnsIfNotActing)

There are usecases where multiple renderers need to oprate inside an act() scope
- ReactDOM.render being used inside another component tree. The parent component will be rendered using ReactTestRenderer.create for a snapshot test or something.
- a ReactDOM instance interacting with a ReactTestRenderer instance (like for the new devtools)

This PR changes the way the acting sigils operate to allow for this. It keeps 2 booleans, one attached to React, one attached to the renderer. act() changes these values, and the workloop reads them to decide what warning to trigger.

I also renamed shouldWarnUnactedUpdates to warnsIfNotActing
@sizebot
Copy link

sizebot commented Jul 2, 2019

ReactDOM: size: 0.0%, gzip: -0.0%

Details of bundled changes.

Comparing: a865e4a...c0ab465

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js 0.0% 0.0% 115 KB 115.01 KB 36.27 KB 36.28 KB NODE_PROFILING
ReactDOM-dev.js -0.0% -0.0% 919.39 KB 919.1 KB 204.05 KB 203.97 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.74 KB 10.74 KB 3.68 KB 3.68 KB UMD_PROD
ReactDOMServer-dev.js 0.0% 0.0% 134.27 KB 134.27 KB 34.45 KB 34.45 KB FB_WWW_DEV
react-dom-unstable-fire.development.js -0.0% -0.0% 896.52 KB 896.23 KB 203.8 KB 203.73 KB UMD_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 111.29 KB 111.3 KB 35.83 KB 35.83 KB UMD_PROD
ReactTestUtils-dev.js +0.3% +0.1% 53.76 KB 53.9 KB 14.4 KB 14.42 KB FB_WWW_DEV
react-dom-unstable-fire.profiling.min.js 0.0% -0.0% 114.73 KB 114.74 KB 36.88 KB 36.88 KB UMD_PROFILING
react-dom-unstable-fire.development.js -0.0% -0.0% 890.81 KB 890.52 KB 202.29 KB 202.21 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 111.37 KB 111.38 KB 35.35 KB 35.35 KB NODE_PROD
react-dom.development.js -0.0% -0.0% 896.18 KB 895.89 KB 203.65 KB 203.58 KB UMD_DEV
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 115.02 KB 115.03 KB 36.28 KB 36.28 KB NODE_PROFILING
react-dom.production.min.js 0.0% 0.0% 111.27 KB 111.28 KB 35.82 KB 35.82 KB UMD_PROD
ReactFire-dev.js -0.0% -0.0% 918.6 KB 918.31 KB 203.95 KB 203.87 KB FB_WWW_DEV
react-dom.profiling.min.js 0.0% -0.0% 114.72 KB 114.73 KB 36.87 KB 36.87 KB UMD_PROFILING
ReactFire-prod.js 0.0% 0.0% 361.45 KB 361.46 KB 66.01 KB 66.01 KB FB_WWW_PROD
react-dom.development.js -0.0% -0.0% 890.47 KB 890.18 KB 202.14 KB 202.07 KB NODE_DEV
ReactFire-profiling.js 0.0% 0.0% 367.75 KB 367.76 KB 67.34 KB 67.35 KB FB_WWW_PROFILING
react-dom.production.min.js 0.0% 0.0% 111.36 KB 111.37 KB 35.34 KB 35.35 KB NODE_PROD
react-dom-server.browser.production.min.js 0.0% -0.0% 19.26 KB 19.26 KB 7.24 KB 7.24 KB NODE_PROD
ReactDOM-prod.js 0.0% 0.0% 373.46 KB 373.48 KB 68.39 KB 68.39 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 379.8 KB 379.82 KB 69.73 KB 69.74 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.48 KB 10.48 KB 3.58 KB 3.58 KB NODE_PROD
react-dom-test-utils.development.js +0.2% +0.1% 57.82 KB 57.96 KB 15.89 KB 15.91 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.1% 10.95 KB 10.95 KB 4.01 KB 4 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.21 KB 1.21 KB 706 B 705 B UMD_PROD
react-dom-test-utils.development.js +0.2% +0.3% 56.08 KB 56.22 KB 15.55 KB 15.59 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1.05 KB 1.05 KB 637 B 636 B NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler-persistent.development.js -0.1% -0.1% 554.87 KB 554.57 KB 117.99 KB 117.91 KB NODE_DEV
react-reconciler-persistent.production.min.js 0.0% 0.0% 68.57 KB 68.58 KB 20.44 KB 20.44 KB NODE_PROD
react-reconciler.development.js -0.1% -0.1% 557.29 KB 556.98 KB 119.04 KB 118.97 KB NODE_DEV
react-reconciler.production.min.js 0.0% 0.0% 68.56 KB 68.56 KB 20.44 KB 20.44 KB NODE_PROD

Generated by 🚫 dangerJS

@threepointone threepointone merged commit a457e02 into facebook:master Jul 2, 2019
@threepointone threepointone deleted the nested-acts-take-2 branch July 2, 2019 21:22
threepointone added a commit to threepointone/react that referenced this pull request Jul 3, 2019
I missed this in facebook#16039. I'd pointed at the wrong previous state, corrupting it in further use. This PR fixes that, and adds a test to make sure it doesn't happen again.
threepointone added a commit to threepointone/react that referenced this pull request Jul 3, 2019
I missed this in facebook#16039. I'd pointed at the wrong previous state, corrupting it in further use. This PR fixes that, and adds a test to make sure it doesn't happen again.
threepointone added a commit to threepointone/react that referenced this pull request Jul 3, 2019
I missed this in facebook#16039. I'd pointed at the wrong previous state, corrupting it in further use. This PR fixes that, and adds a test to make sure it doesn't happen again.
threepointone added a commit that referenced this pull request Jul 3, 2019
* [fail] reset IsThisRendererActing correctly

I missed this in #16039. I'd pointed at the wrong previous state, corrupting it in further use. This PR fixes that, and adds a test to make sure it doesn't happen again.

* warn for unacted effects only in strict mode
trueadm pushed a commit to trueadm/react that referenced this pull request Jul 3, 2019
* allow nested `act()`s from different renderers

There are usecases where multiple renderers need to oprate inside an act() scope
- ReactDOM.render being used inside another component tree. The parent component will be rendered using ReactTestRenderer.create for a snapshot test or something.
- a ReactDOM instance interacting with a ReactTestRenderer instance (like for the new devtools)

This PR changes the way the acting sigils operate to allow for this. It keeps 2 booleans, one attached to React, one attached to the renderer. act() changes these values, and the workloop reads them to decide what warning to trigger.

I also renamed shouldWarnUnactedUpdates to warnsIfNotActing

* s/ReactIsActing/IsSomeRendererActing and s/ReactRendererIsActing/IsThisRendererActing
trueadm pushed a commit to trueadm/react that referenced this pull request Jul 3, 2019
* [fail] reset IsThisRendererActing correctly

I missed this in facebook#16039. I'd pointed at the wrong previous state, corrupting it in further use. This PR fixes that, and adds a test to make sure it doesn't happen again.

* warn for unacted effects only in strict mode
@@ -823,7 +823,7 @@ const ReactDOM: Object = {
dispatchEvent,
runEventsInBatch,
flushPassiveEffects,
ReactActingRendererSigil,
IsThisRendererActing,
Copy link
Collaborator

Choose a reason for hiding this comment

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

threepointone added a commit to threepointone/react that referenced this pull request Jul 11, 2019
after facebook#16039, act was broken for umd builds. This PR fixes it.
threepointone added a commit to threepointone/react that referenced this pull request Jul 11, 2019
after facebook#16039, act was broken for umd builds. This PR fixes it.
threepointone pushed a commit that referenced this pull request Jul 11, 2019
after #16039, act was broken for umd builds. This PR fixes it.
@gaearon gaearon mentioned this pull request Jul 30, 2019
This was referenced Mar 10, 2020
renawolford6 added a commit to renawolford6/react-shallow-renderer that referenced this pull request Nov 10, 2022
* [fail] reset IsThisRendererActing correctly

I missed this in facebook/react#16039. I'd pointed at the wrong previous state, corrupting it in further use. This PR fixes that, and adds a test to make sure it doesn't happen again.

* warn for unacted effects only in strict mode
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.

None yet

5 participants