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

[act] with nested act()s from different renderers, flush work on exiting outermost act() #16181

Merged

Conversation

threepointone
Copy link
Contributor

Given this snippet:

TestRenderer.act(() => {
  TestUtils.act(() => {
    TestRenderer.create(<Effecty />);
  });
});

We want to make sure that all work is only flushed on exiting the outermost act().

Now, naively doing this based on actingScopeDepth would work with a mocked scheduler, where flushAll() would flush all work across renderers.

This doesn't work without mocking the scheduler though; and where flushing work only works per renderer. So we disable this behaviour for a non-mocked scenario. This seems like an ok tradeoff.

@sizebot
Copy link

sizebot commented Jul 23, 2019

Details of bundled changes.

Comparing: 5098891...630b77d

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.1% 0.0% 596.25 KB 596.55 KB 124.49 KB 124.53 KB FB_WWW_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 11.62 KB 11.62 KB 3.55 KB 3.55 KB UMD_PROD
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.77 KB 11.77 KB 3.67 KB 3.67 KB NODE_PROD
react-test-renderer.development.js 0.0% 0.0% 584.59 KB 584.81 KB 125.14 KB 125.18 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.3% 🔺+0.4% 68.78 KB 68.96 KB 21.02 KB 21.09 KB UMD_PROD
react-test-renderer.development.js 0.0% 0.0% 580.14 KB 580.35 KB 124.02 KB 124.05 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.3% 🔺+0.3% 68.53 KB 68.71 KB 20.81 KB 20.88 KB NODE_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactDOM-dev.js 0.0% -0.0% 927.91 KB 927.91 KB 205.32 KB 205.32 KB FB_WWW_DEV
react-dom-test-utils.development.js +0.4% +0.3% 58 KB 58.21 KB 15.92 KB 15.96 KB UMD_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.78 KB 3.78 KB 1.52 KB 1.52 KB UMD_DEV
react-dom-test-utils.production.min.js 🔺+2.0% 🔺+2.3% 10.95 KB 11.17 KB 4.01 KB 4.1 KB UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.1% 1.21 KB 1.21 KB 707 B 706 B UMD_PROD
react-dom-test-utils.development.js +0.4% +0.3% 56.26 KB 56.48 KB 15.6 KB 15.65 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.61 KB 3.61 KB 1.48 KB 1.48 KB NODE_DEV
react-dom-test-utils.production.min.js 🔺+2.3% 🔺+2.3% 10.71 KB 10.95 KB 3.94 KB 4.04 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% -0.2% 1.05 KB 1.05 KB 638 B 637 B NODE_PROD
react-dom.development.js 0.0% -0.0% 904.34 KB 904.34 KB 204.87 KB 204.87 KB UMD_DEV
react-dom.production.min.js 0.0% -0.0% 111.46 KB 111.46 KB 35.79 KB 35.79 KB UMD_PROD
ReactTestUtils-dev.js +0.6% +0.4% 53.9 KB 54.2 KB 14.42 KB 14.48 KB FB_WWW_DEV
react-dom-server.node.development.js 0.0% 0.0% 134.49 KB 134.49 KB 35.64 KB 35.64 KB NODE_DEV
react-dom.production.min.js 0.0% -0.0% 111.51 KB 111.51 KB 35.29 KB 35.29 KB NODE_PROD
ReactDOM-prod.js 0.0% 0.0% 372.02 KB 372.02 KB 68.35 KB 68.35 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 376.86 KB 376.86 KB 69.43 KB 69.44 KB FB_WWW_PROFILING
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
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
react-dom-unstable-fizz.node.production.min.js 0.0% -0.1% 1.1 KB 1.1 KB 668 B 667 B NODE_PROD

Generated by 🚫 dangerJS

@threepointone threepointone marked this pull request as ready for review July 23, 2019 09:41
@threepointone threepointone changed the title WIP: with nested act()s from different renderers, flush work on exiting outermost act() [act] with nested act()s from different renderers, flush work on exiting outermost act() Jul 23, 2019
@threepointone threepointone requested a review from acdlite July 23, 2019 10:02
@threepointone threepointone force-pushed the flush-outside-nested-acts branch from 33b6b43 to e42abd4 Compare July 23, 2019 10:02
…ent renderers

Given this snippet:
```jsx
    TestRenderer.act(() => {
      TestUtils.act(() => {
        TestRenderer.create(<Effecty />);
      });
    });
```
We want to make sure that all work is only flushed on exiting the outermost act().

Now, naively doing this based on actingScopeDepth would work with a mocked scheduler, where flushAll() would flush all work across renderers.

This doesn't work without mocking the scheduler though; and where flushing work only works per renderer. So we disable this behaviour for a non-mocked scenario. This seems like an ok tradeoff.
@threepointone threepointone force-pushed the flush-outside-nested-acts branch from e42abd4 to 630b77d Compare July 23, 2019 23:14
@threepointone threepointone merged commit c73e1f2 into facebook:master Jul 23, 2019
@threepointone threepointone deleted the flush-outside-nested-acts branch July 23, 2019 23:20
NMinhNguyen referenced this pull request in enzymejs/react-shallow-renderer Jan 29, 2020
…ent renderers (#16181)

Given this snippet:
```jsx
    TestRenderer.act(() => {
      TestUtils.act(() => {
        TestRenderer.create(<Effecty />);
      });
    });
```
We want to make sure that all work is only flushed on exiting the outermost act().

Now, naively doing this based on actingScopeDepth would work with a mocked scheduler, where flushAll() would flush all work across renderers.

This doesn't work without mocking the scheduler though; and where flushing work only works per renderer. So we disable this behaviour for a non-mocked scenario. This seems like an ok tradeoff.
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.

4 participants