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

Warn if calling setState outside of render but before commit #18838

Merged
merged 2 commits into from
May 6, 2020

Conversation

sebmarkbage
Copy link
Collaborator

@sebmarkbage sebmarkbage commented May 6, 2020

This indicates that there's a side-effect spawned during render, that then asynchronously tries to set state when the response comes back. E.g. kick off a request and then setState with the result. It's a common mistake when implementing Suspense.

This should be done in useEffect.

@sebmarkbage sebmarkbage requested review from bvaughn and acdlite May 6, 2020 06:25
@facebook-github-bot facebook-github-bot added React Core Team Opened by a member of the React Core Team CLA Signed labels May 6, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented May 6, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2e018a9:

Sandbox Source
sad-fire-4pcwu Configuration

@sizebot
Copy link

sizebot commented May 6, 2020

Details of bundled changes.

Comparing: 33c3af2...2e018a9

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom-test-utils.development.js 0.0% 0.0% 75.29 KB 75.29 KB 20.19 KB 20.19 KB UMD_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 5.36 KB 5.36 KB 1.8 KB 1.81 KB UMD_DEV
ReactDOMTesting-dev.js +0.2% +0.1% 928.65 KB 930.9 KB 207.8 KB 208.11 KB FB_WWW_DEV
react-dom.development.js +0.2% +0.2% 942.77 KB 944.97 KB 206.49 KB 206.84 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 124.63 KB 124.63 KB 39.91 KB 39.91 KB UMD_PROD
ReactDOMForked-dev.js +0.2% +0.2% 1011.49 KB 1013.75 KB 227.19 KB 227.53 KB FB_WWW_DEV
react-dom.profiling.min.js 0.0% -0.0% 128.51 KB 128.51 KB 41.07 KB 41.07 KB UMD_PROFILING
ReactDOMForked-prod.js 0.0% 0.0% 418.45 KB 418.48 KB 75.41 KB 75.41 KB FB_WWW_PROD
react-dom.development.js +0.2% +0.2% 897.57 KB 899.68 KB 203.93 KB 204.27 KB NODE_DEV
ReactDOMForked-profiling.js 0.0% 0.0% 428.15 KB 428.18 KB 77.06 KB 77.07 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 152.74 KB 152.74 KB 40.52 KB 40.52 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 124.81 KB 124.81 KB 39.01 KB 39.01 KB NODE_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 23.32 KB 23.32 KB 8.6 KB 8.6 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 128.84 KB 128.85 KB 40.3 KB 40.31 KB NODE_PROFILING
ReactDOM-dev.js +0.2% +0.1% 1015.36 KB 1017.61 KB 226.43 KB 226.76 KB FB_WWW_DEV
ReactDOMServer-dev.js 0.0% 0.0% 160.35 KB 160.35 KB 40.85 KB 40.85 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 422.85 KB 422.88 KB 74.79 KB 74.8 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 433.75 KB 433.78 KB 76.63 KB 76.63 KB FB_WWW_PROFILING
ReactDOMTesting-prod.js 0.0% 0.0% 392.9 KB 392.93 KB 72.68 KB 72.69 KB FB_WWW_PROD
react-dom-test-utils.production.min.js 0.0% -0.0% 13.06 KB 13.06 KB 4.81 KB 4.81 KB NODE_PROD
react-dom-server.node.production.min.js 0.0% 0.0% 23.73 KB 23.73 KB 8.75 KB 8.75 KB NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.3% +0.3% 660.89 KB 663.09 KB 139.46 KB 139.81 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 110.89 KB 110.9 KB 33.59 KB 33.6 KB UMD_PROD
react-art.development.js +0.4% +0.3% 564.08 KB 566.18 KB 121.95 KB 122.28 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 75.84 KB 75.85 KB 22.8 KB 22.8 KB NODE_PROD
ReactART-dev.js +0.4% +0.3% 599.75 KB 602 KB 126.46 KB 126.79 KB FB_WWW_DEV
ReactART-prod.js 0.0% 0.0% 242.41 KB 242.44 KB 41.38 KB 41.38 KB FB_WWW_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 12.74 KB 12.74 KB 3.97 KB 3.97 KB UMD_PROD
ReactTestRenderer-dev.js +0.4% +0.3% 574.19 KB 576.43 KB 121.76 KB 122.1 KB FB_WWW_DEV
react-test-renderer.development.js +0.4% +0.3% 573.42 KB 575.61 KB 119.78 KB 120.13 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 74.65 KB 74.65 KB 22.78 KB 22.79 KB UMD_PROD
react-test-renderer.development.js +0.4% +0.3% 546.73 KB 548.83 KB 118.37 KB 118.71 KB NODE_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.3% +0.3% 620.42 KB 622.53 KB 131.71 KB 132.07 KB NODE_DEV
react-reconciler.production.min.js 0.0% 0.0% 85.31 KB 85.31 KB 25.5 KB 25.5 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-prod.js 0.0% -0.0% 264.09 KB 264.09 KB 45.47 KB 45.47 KB RN_OSS_PROD
ReactNativeRenderer-prod.js 0.0% -0.0% 272.17 KB 272.17 KB 46.99 KB 46.99 KB RN_OSS_PROD
ReactNativeRenderer-dev.js +0.3% +0.2% 662.37 KB 664.62 KB 142.42 KB 142.76 KB RN_FB_DEV
ReactNativeRenderer-profiling.js 0.0% -0.0% 283.59 KB 283.59 KB 49.2 KB 49.19 KB RN_FB_PROFILING
ReactFabric-dev.js +0.4% +0.2% 638.97 KB 641.21 KB 137.2 KB 137.54 KB RN_OSS_DEV
ReactFabric-dev.js +0.3% +0.3% 643.42 KB 645.66 KB 137.86 KB 138.21 KB RN_FB_DEV
ReactNativeRenderer-dev.js +0.3% +0.2% 657.93 KB 660.17 KB 141.75 KB 142.09 KB RN_OSS_DEV

Size changes (experimental)

Generated by 🚫 dangerJS against 2e018a9

@sizebot
Copy link

sizebot commented May 6, 2020

Details of bundled changes.

Comparing: 33c3af2...2e018a9

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-dev.js +0.4% +0.3% 638.96 KB 641.2 KB 137.19 KB 137.54 KB RN_OSS_DEV
ReactNativeRenderer-dev.js +0.3% +0.2% 657.92 KB 660.16 KB 141.75 KB 142.08 KB RN_OSS_DEV
ReactNativeRenderer-profiling.js 0.0% -0.0% 283.63 KB 283.63 KB 49.21 KB 49.21 KB RN_OSS_PROFILING
ReactFabric-prod.js 0.0% -0.0% 264.07 KB 264.07 KB 45.46 KB 45.46 KB RN_OSS_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactDOM-profiling.js 0.0% 0.0% 445.27 KB 445.31 KB 78.65 KB 78.65 KB FB_WWW_PROFILING
react-dom-test-utils.production.min.js 0.0% -0.0% 13.05 KB 13.05 KB 4.8 KB 4.8 KB NODE_PROD
react-dom-server.browser.development.js 0.0% -0.0% 154.95 KB 154.95 KB 39.49 KB 39.49 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.16 KB 1.16 KB 659 B 660 B NODE_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 22.97 KB 22.97 KB 8.53 KB 8.54 KB UMD_PROD
ReactDOMForked-dev.js +0.2% +0.1% 1.01 MB 1.01 MB 232.89 KB 233.23 KB FB_WWW_DEV
ReactDOMForked-prod.js 0.0% 0.0% 430.03 KB 430.06 KB 77.46 KB 77.46 KB FB_WWW_PROD
react-dom.development.js +0.2% +0.2% 908.91 KB 911.1 KB 200.03 KB 200.36 KB UMD_DEV
ReactDOMForked-profiling.js 0.0% 0.0% 439.79 KB 439.82 KB 79.1 KB 79.1 KB FB_WWW_PROFILING
react-dom.profiling.min.js 0.0% -0.0% 123.61 KB 123.61 KB 39.63 KB 39.63 KB UMD_PROFILING
ReactDOMTesting-dev.js +0.2% +0.1% 954.44 KB 956.69 KB 213.32 KB 213.63 KB FB_WWW_DEV
react-dom.development.js +0.2% +0.2% 865.15 KB 867.25 KB 197.48 KB 197.84 KB NODE_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 404.75 KB 404.78 KB 74.7 KB 74.71 KB FB_WWW_PROD
react-dom-server.node.development.js 0.0% -0.0% 147.01 KB 147.01 KB 38.97 KB 38.97 KB NODE_DEV
react-dom-test-utils.development.js 0.0% 0.0% 75.28 KB 75.28 KB 20.18 KB 20.18 KB UMD_DEV
ReactDOM-dev.js +0.2% +0.1% 1.02 MB 1.02 MB 232.05 KB 232.38 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 434.31 KB 434.34 KB 76.8 KB 76.8 KB FB_WWW_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 5.35 KB 5.35 KB 1.8 KB 1.8 KB UMD_DEV
ReactDOMServer-dev.js 0.0% -0.0% 163.85 KB 163.85 KB 41.76 KB 41.76 KB FB_WWW_DEV
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 4.85 KB 4.85 KB 1.7 KB 1.7 KB NODE_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-dev.js +0.4% +0.2% 609.77 KB 612.02 KB 128.49 KB 128.81 KB FB_WWW_DEV
ReactART-prod.js 0.0% 0.0% 249.45 KB 249.48 KB 42.62 KB 42.63 KB FB_WWW_PROD
react-art.development.js +0.3% +0.3% 636.51 KB 638.7 KB 134.58 KB 134.93 KB UMD_DEV
react-art.production.min.js 0.0% -0.0% 107.53 KB 107.53 KB 32.63 KB 32.63 KB UMD_PROD
react-art.development.js +0.4% +0.3% 540.7 KB 542.8 KB 117.01 KB 117.34 KB NODE_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.4% +0.3% 574.17 KB 576.42 KB 121.75 KB 122.09 KB FB_WWW_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 12.73 KB 12.73 KB 3.96 KB 3.97 KB UMD_PROD
react-test-renderer.development.js +0.4% +0.3% 573.39 KB 575.58 KB 119.77 KB 120.12 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 74.63 KB 74.63 KB 22.76 KB 22.77 KB UMD_PROD
react-test-renderer.development.js +0.4% +0.3% 546.7 KB 548.8 KB 118.36 KB 118.69 KB NODE_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.4% +0.3% 594.66 KB 596.76 KB 126.27 KB 126.64 KB NODE_DEV

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (stable)

Generated by 🚫 dangerJS against 2e018a9

The DehydratedFragment tag doesn't exist so doing so throws.

This can happen if we schedule childExpirationTime on the boundary and
bail out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants