Skip to content

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Aug 2, 2019

The clean-up function of a passive effect (useEffect) usually fires in a post-commit task, after the browser has painted. However, there is an exception when the component (or its parent) is deleted from the tree. In that case, we fire the clean-up function during the synchronous commit phase, the same phase we use for layout effects.

This is a concession to implementation complexity. Calling it in the passive effect phase would require either traversing the children of the deleted fiber again, or including unmount effects as part of the fiber effect list.

Because the functions are called during the sync phase in this case, the Scheduler priority is Immediate (the one used for layout) instead of Normal. We may want to reconsider this trade off later.

In practice, this should rarely matter because it's unusual to call setState inside a clean-up function. We might want to warn about this pattern.

The clean-up function of a passive effect (`useEffect`) usually fires
in a post-commit task, after the browser has painted. However, there is
an exception when the component (or its parent) is deleted from the
tree. In that case, we fire the clean-up function during the
synchronous commit phase, the same phase we use for layout effects.

This is a concession to implementation complexity. Calling it in the
passive effect phase would require either traversing the children of the
deleted fiber again, or including unmount effects as part of the fiber
effect list.

Because the functions are called during the sync phase in this case,
the Scheduler priority is Immediate (the one used for layout) instead
of Normal. We may want to reconsider this trade off later.
@sizebot
Copy link

sizebot commented Aug 2, 2019

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

Details of bundled changes.

Comparing: f440bfd...7df2aa6

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.2% +0.2% 645.05 KB 646.24 KB 140.71 KB 141 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 0.0% 102.64 KB 102.71 KB 31.32 KB 31.34 KB UMD_PROD
react-art.development.js +0.2% +0.2% 575.92 KB 577.11 KB 123.41 KB 123.7 KB NODE_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 67.68 KB 67.76 KB 20.65 KB 20.68 KB NODE_PROD
ReactART-dev.js +0.2% +0.3% 589.85 KB 591.09 KB 122.98 KB 123.29 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.3% 🔺+0.2% 221.31 KB 221.9 KB 37.77 KB 37.85 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-prod.js 🔺+0.2% 🔺+0.2% 272.81 KB 273.38 KB 46.86 KB 46.97 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.2% +0.2% 281.23 KB 281.79 KB 48.38 KB 48.47 KB RN_OSS_PROFILING
ReactFabric-prod.js -0.1% 0.0% 266.49 KB 266.2 KB 45.9 KB 45.9 KB RN_OSS_PROD
ReactFabric-profiling.js -0.1% -0.1% 275.15 KB 274.87 KB 47.35 KB 47.33 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.2% +0.2% 736.58 KB 737.83 KB 155.7 KB 155.98 KB RN_FB_DEV
ReactFabric-prod.js -0.1% 0.0% 266.49 KB 266.2 KB 45.91 KB 45.91 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.2% +0.2% 723.86 KB 725.11 KB 153.25 KB 153.53 KB RN_OSS_DEV
ReactFabric-profiling.js -0.1% -0.1% 275.15 KB 274.87 KB 47.36 KB 47.34 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.2% +0.2% 723.96 KB 725.2 KB 153.3 KB 153.58 KB RN_FB_DEV
ReactNativeRenderer-prod.js 🔺+0.2% 🔺+0.2% 272.8 KB 273.37 KB 46.87 KB 46.98 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.2% +0.2% 281.22 KB 281.78 KB 48.39 KB 48.48 KB RN_FB_PROFILING
ReactFabric-dev.js +0.2% +0.2% 736.48 KB 737.72 KB 155.66 KB 155.94 KB RN_OSS_DEV

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js +0.1% +0.1% 115.36 KB 115.44 KB 36.32 KB 36.36 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 136.93 KB 136.93 KB 36.2 KB 36.2 KB UMD_DEV
ReactDOM-dev.js +0.1% +0.1% 932.86 KB 934.11 KB 206.36 KB 206.65 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.35 KB 19.35 KB 7.24 KB 7.24 KB UMD_PROD
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 0.0% 0.0% 11.19 KB 11.19 KB 4.1 KB 4.11 KB UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.61 KB 3.61 KB 1.48 KB 1.47 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.97 KB 10.97 KB 4.04 KB 4.04 KB NODE_PROD
react-dom.development.js +0.1% +0.1% 909.4 KB 910.59 KB 206.04 KB 206.32 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 111.67 KB 111.76 KB 35.9 KB 35.96 KB UMD_PROD
react-dom.profiling.min.js +0.1% +0.2% 115.09 KB 115.17 KB 36.9 KB 36.97 KB UMD_PROFILING
react-dom.development.js +0.1% +0.1% 903.7 KB 904.89 KB 204.55 KB 204.84 KB NODE_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 111.71 KB 111.79 KB 35.36 KB 35.4 KB NODE_PROD
ReactDOM-prod.js 🔺+0.2% 🔺+0.1% 373.6 KB 374.17 KB 68.63 KB 68.71 KB FB_WWW_PROD
ReactDOM-profiling.js +0.2% +0.1% 378.25 KB 378.82 KB 69.7 KB 69.76 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 133.06 KB 133.06 KB 35.27 KB 35.27 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.28 KB 19.28 KB 7.25 KB 7.25 KB NODE_PROD
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
ReactDOMServer-dev.js 0.0% -0.0% 135.09 KB 135.09 KB 34.66 KB 34.65 KB FB_WWW_DEV
ReactDOMServer-prod.js 0.0% -0.0% 46.3 KB 46.3 KB 10.72 KB 10.72 KB FB_WWW_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-fizz.node.development.js 0.0% -0.1% 3.85 KB 3.85 KB 1.5 KB 1.5 KB NODE_DEV
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-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.2% +0.2% 600.83 KB 602.08 KB 125.43 KB 125.73 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 39.37 KB 39.37 KB 9.92 KB 9.92 KB UMD_DEV
react-test-renderer.development.js +0.2% +0.2% 588.84 KB 590.03 KB 126 KB 126.29 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.2% 69.24 KB 69.32 KB 21.18 KB 21.23 KB UMD_PROD
react-test-renderer.development.js +0.2% +0.2% 584.38 KB 585.57 KB 124.88 KB 125.17 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 68.98 KB 69.06 KB 20.96 KB 20.98 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.2% 574.01 KB 575.2 KB 121.99 KB 122.25 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.2% 🔺+0.2% 68.9 KB 69 KB 20.48 KB 20.52 KB NODE_PROD
react-reconciler-reflection.development.js 0.0% 0.0% 16.63 KB 16.63 KB 5.16 KB 5.16 KB NODE_DEV
react-reconciler-persistent.development.js +0.2% +0.2% 571.02 KB 572.21 KB 120.71 KB 120.98 KB NODE_DEV
react-reconciler-persistent.production.min.js 🔺+0.2% 🔺+0.2% 68.91 KB 69.01 KB 20.48 KB 20.52 KB NODE_PROD

Generated by 🚫 dangerJS

@acdlite acdlite merged commit 05dce75 into facebook:master Aug 2, 2019
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