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

commented Jul 2, 2019

(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)

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
@sizebot

This comment has been minimized.

Copy link

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

13 checks passed

ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: flow Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: lint_build Your tests passed on CircleCI!
Details
ci/circleci: process_artifacts Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: test_build Your tests passed on CircleCI!
Details
ci/circleci: test_build_prod Your tests passed on CircleCI!
Details
ci/circleci: test_dom_fixtures Your tests passed on CircleCI!
Details
ci/circleci: test_source Your tests passed on CircleCI!
Details
ci/circleci: test_source_fire Your tests passed on CircleCI!
Details
ci/circleci: test_source_persistent Your tests passed on CircleCI!
Details
ci/circleci: test_source_prod Your tests passed on CircleCI!
Details

@threepointone threepointone deleted the threepointone:nested-acts-take-2 branch Jul 2, 2019

threepointone added a commit to threepointone/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.

threepointone added a commit to threepointone/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.

threepointone added a commit to threepointone/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.

threepointone added a commit that referenced this pull request Jul 3, 2019

[fail] reset IsThisRendererActing correctly (#16042)
* [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 added a commit to trueadm/react that referenced this pull request Jul 3, 2019

allow nested `act()`s from different renderers (facebook#16039)
* 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 added a commit to trueadm/react that referenced this pull request Jul 3, 2019

[fail] reset IsThisRendererActing correctly (facebook#16042)
* [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,

This comment has been minimized.

Copy link
@gaearon

gaearon Jul 4, 2019

Member

threepointone added a commit to threepointone/react that referenced this pull request Jul 11, 2019

expose act() sigil correctly for umd builds
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

expose act() sigil correctly for umd builds
after facebook#16039, act was broken for umd builds. This PR fixes it.

threepointone added a commit that referenced this pull request Jul 11, 2019

expose act() sigil correctly for umd builds (#16110)
after #16039, act was broken for umd builds. This PR fixes it.
@gaearon gaearon referenced this pull request Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.