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

Double-render function components in DEV in StrictMode #14639

Closed
wants to merge 3 commits into from

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Jan 19, 2019

@acdlite noticed we're not doing this, but we should. It's DEV-only. Function components already need to not have observable side effects — so I think this is perfectly reasonable to do in a minor.

The test changes are a bit wonky. Maybe we could abstract this away but I felt it's only a few files for now and not too bad.

@sizebot
Copy link

sizebot commented Jan 19, 2019

ReactDOM: size: 0.0%, gzip: 0.0%

Details of bundled changes.

Comparing: 10a7a5b...f836352

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.1% 0.0% 733.09 KB 733.74 KB 169.09 KB 169.12 KB UMD_DEV
react-dom.production.min.js 0.0% 0.0% 98.98 KB 98.98 KB 32.2 KB 32.2 KB UMD_PROD
react-dom.profiling.min.js 0.0% 0.0% 101.97 KB 101.97 KB 32.84 KB 32.84 KB UMD_PROFILING
react-dom.development.js +0.1% 0.0% 728.15 KB 728.8 KB 167.66 KB 167.7 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 98.99 KB 98.99 KB 31.68 KB 31.68 KB NODE_PROD
react-dom.profiling.min.js 0.0% 0.0% 102.09 KB 102.09 KB 32.3 KB 32.31 KB NODE_PROFILING
ReactDOM-dev.js +0.1% +0.1% 750.17 KB 751.07 KB 168.83 KB 168.94 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 311.52 KB 311.52 KB 57.5 KB 57.5 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 318.68 KB 318.68 KB 58.83 KB 58.83 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js +0.1% 0.0% 733.43 KB 734.09 KB 169.23 KB 169.27 KB UMD_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 99 KB 99 KB 32.21 KB 32.21 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 101.98 KB 101.98 KB 32.84 KB 32.85 KB UMD_PROFILING
react-dom-unstable-fire.development.js +0.1% 0.0% 728.49 KB 729.15 KB 167.8 KB 167.84 KB NODE_DEV
react-dom-unstable-fire.production.min.js 0.0% 0.0% 99 KB 99 KB 31.69 KB 31.69 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js 0.0% 0.0% 102.1 KB 102.1 KB 32.31 KB 32.31 KB NODE_PROFILING
ReactFire-dev.js +0.1% +0.1% 749.38 KB 750.28 KB 168.78 KB 168.89 KB FB_WWW_DEV
ReactFire-prod.js 0.0% 0.0% 300.11 KB 300.11 KB 55.22 KB 55.23 KB FB_WWW_PROD
ReactFire-profiling.js 0.0% 0.0% 307.2 KB 307.2 KB 56.51 KB 56.51 KB FB_WWW_PROFILING
react-dom-test-utils.development.js 0.0% 0.0% 44.87 KB 44.87 KB 12.3 KB 12.3 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% 🔺+0.1% 9.97 KB 9.97 KB 3.71 KB 3.71 KB UMD_PROD
react-dom-test-utils.production.min.js 0.0% 0.0% 9.74 KB 9.74 KB 3.65 KB 3.65 KB NODE_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.61 KB 60.61 KB 15.92 KB 15.92 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 11.01 KB 11.01 KB 3.81 KB 3.81 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 60.29 KB 60.29 KB 15.79 KB 15.79 KB NODE_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 🔺+0.1% 10.75 KB 10.75 KB 3.71 KB 3.71 KB NODE_PROD
react-dom-server.browser.development.js 0.0% 0.0% 125.09 KB 125.09 KB 33.35 KB 33.35 KB UMD_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 16.96 KB 16.96 KB 6.53 KB 6.53 KB UMD_PROD
react-dom-server.browser.development.js 0.0% 0.0% 121.22 KB 121.22 KB 32.43 KB 32.43 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 16.87 KB 16.87 KB 6.51 KB 6.51 KB NODE_PROD
react-dom-server.node.development.js 0.0% 0.0% 123.28 KB 123.28 KB 32.97 KB 32.97 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 17.74 KB 17.74 KB 6.83 KB 6.83 KB NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.63 KB 3.63 KB 1.44 KB 1.44 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.21 KB 1.21 KB 706 B 707 B UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.45 KB 3.45 KB 1.39 KB 1.39 KB NODE_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.3% 1.05 KB 1.05 KB 636 B 638 B NODE_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 3.7 KB 3.7 KB 1.42 KB 1.42 KB NODE_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.3% 1.1 KB 1.1 KB 666 B 668 B NODE_PROD

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% 0.0% 511.94 KB 512.59 KB 112.92 KB 112.96 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 91.04 KB 91.04 KB 27.97 KB 27.97 KB UMD_PROD
react-art.development.js +0.1% 0.0% 443.46 KB 444.11 KB 95.81 KB 95.84 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 56.01 KB 56.01 KB 17.25 KB 17.25 KB NODE_PROD
ReactART-dev.js +0.2% +0.1% 451.89 KB 452.79 KB 94.87 KB 94.98 KB FB_WWW_DEV
ReactART-prod.js 0.0% 0.0% 187.42 KB 187.42 KB 32.15 KB 32.15 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.2% +0.1% 576.38 KB 577.28 KB 125.38 KB 125.48 KB RN_FB_DEV
ReactNativeRenderer-profiling.js 0.0% 0.0% 249.1 KB 249.1 KB 44.09 KB 44.09 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.2% +0.1% 576.3 KB 577.2 KB 125.34 KB 125.45 KB RN_OSS_DEV
ReactNativeRenderer-profiling.js 0.0% 0.0% 233.24 KB 233.24 KB 40.89 KB 40.89 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.2% +0.1% 567.24 KB 568.14 KB 123.09 KB 123.2 KB RN_FB_DEV
ReactFabric-prod.js 0.0% 0.0% 236.16 KB 236.16 KB 41.27 KB 41.27 KB RN_FB_PROD
ReactFabric-dev.js +0.2% +0.1% 567.14 KB 568.04 KB 123.06 KB 123.16 KB RN_OSS_DEV
ReactFabric-prod.js 0.0% 0.0% 220.46 KB 220.46 KB 38.04 KB 38.05 KB RN_OSS_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +0.1% 0.0% 456.67 KB 457.33 KB 98.58 KB 98.61 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 57.41 KB 57.41 KB 17.62 KB 17.63 KB UMD_PROD
react-test-renderer.development.js +0.1% 0.0% 451.63 KB 452.29 KB 97.34 KB 97.38 KB NODE_DEV
react-test-renderer.production.min.js 0.0% 0.0% 57.08 KB 57.08 KB 17.47 KB 17.47 KB NODE_PROD
ReactTestRenderer-dev.js +0.2% +0.1% 460.28 KB 461.18 KB 96.75 KB 96.86 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% 0.0% 38.09 KB 38.09 KB 9.83 KB 9.83 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 🔺+0.1% 10.56 KB 10.56 KB 3.25 KB 3.25 KB UMD_PROD
react-test-renderer-shallow.development.js 0.0% 0.0% 32.39 KB 32.39 KB 8.46 KB 8.46 KB NODE_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 11.2 KB 11.2 KB 3.49 KB 3.49 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.1% 0.0% 441.29 KB 441.94 KB 94.33 KB 94.36 KB NODE_DEV
react-reconciler-persistent.development.js +0.1% 0.0% 439.67 KB 440.32 KB 93.68 KB 93.71 KB NODE_DEV
react-reconciler-reflection.production.min.js 0.0% 🔺+0.1% 2.56 KB 2.56 KB 1.13 KB 1.13 KB NODE_PROD

Generated by 🚫 dangerJS

TestRenderer is built with strict mode doublerender off.

We could change that but I'm not sure we want to. So I'll just flip the flag off for this test.
@bvaughn
Copy link
Contributor

bvaughn commented Jan 19, 2019

This change might be observable in a way that breaks existing tests (e.g. if I mock a module/component and then assert on the number of renders). Not sure how common this is, and also– I think this change might still be the right thing to do in a minor. Just seemed worth considering.

@gaearon
Copy link
Collaborator Author

gaearon commented Jan 21, 2019

We can do that but for now I'll go with #14643 instead

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