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 with Hooks in DEV in StrictMode #14643

Merged
merged 5 commits into from Jan 21, 2019

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Jan 21, 2019

Alternative to #14639. (See last commit.)

Less risky. Would make DEV faster for the stateless case. It's mostly Hooks abuse that we're worried about anyway. Added a test for useMemo(fn, []) specifically.

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.
@sizebot
Copy link

sizebot commented Jan 21, 2019

Details of bundled changes.

Comparing: 10a7a5b...ee5cb17

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 734.09 KB 169.09 KB 169.16 KB UMD_DEV
react-dom.development.js +0.1% 0.0% 728.15 KB 729.15 KB 167.66 KB 167.73 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
ReactDOM-dev.js +0.2% +0.1% 750.17 KB 751.48 KB 168.83 KB 169.01 KB FB_WWW_DEV
react-dom-unstable-fire.development.js +0.1% 0.0% 733.43 KB 734.44 KB 169.23 KB 169.3 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.development.js +0.1% 0.0% 728.49 KB 729.5 KB 167.8 KB 167.88 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
ReactFire-dev.js +0.2% +0.1% 749.38 KB 750.69 KB 168.78 KB 168.96 KB FB_WWW_DEV
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-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.2% +0.1% 511.94 KB 512.94 KB 112.92 KB 113 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.2% +0.1% 443.46 KB 444.46 KB 95.81 KB 95.88 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.3% +0.2% 451.89 KB 453.2 KB 94.87 KB 95.05 KB FB_WWW_DEV

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.69 KB 125.38 KB 125.55 KB RN_FB_DEV
ReactNativeRenderer-dev.js +0.2% +0.1% 576.3 KB 577.61 KB 125.34 KB 125.52 KB RN_OSS_DEV
ReactNativeRenderer-prod.js 0.0% -0.0% 227.23 KB 227.23 KB 39.51 KB 39.51 KB RN_OSS_PROD
ReactFabric-dev.js +0.2% +0.1% 567.24 KB 568.55 KB 123.09 KB 123.27 KB RN_FB_DEV
ReactFabric-dev.js +0.2% +0.1% 567.14 KB 568.45 KB 123.06 KB 123.23 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
ReactFabric-profiling.js 0.0% -0.0% 225.55 KB 225.55 KB 39.43 KB 39.43 KB RN_OSS_PROFILING

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer.development.js +0.2% +0.1% 456.67 KB 457.67 KB 98.58 KB 98.65 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 57.41 KB 57.41 KB 17.62 KB 17.62 KB UMD_PROD
react-test-renderer.development.js +0.2% +0.1% 451.63 KB 452.63 KB 97.34 KB 97.41 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.3% +0.2% 460.28 KB 461.59 KB 96.75 KB 96.93 KB FB_WWW_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 10.56 KB 10.56 KB 3.25 KB 3.25 KB UMD_PROD
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.2% +0.1% 441.29 KB 442.29 KB 94.33 KB 94.39 KB NODE_DEV
react-reconciler.production.min.js 0.0% -0.0% 57.17 KB 57.17 KB 17.07 KB 17.07 KB NODE_PROD
react-reconciler-persistent.development.js +0.2% +0.1% 439.67 KB 440.67 KB 93.68 KB 93.74 KB NODE_DEV
react-reconciler-persistent.production.min.js 0.0% -0.0% 57.18 KB 57.18 KB 17.08 KB 17.08 KB NODE_PROD

Generated by 🚫 dangerJS

Copy link
Contributor

@trueadm trueadm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I much prefer this approach. Less risky and also not a breaking change (even if the logic from before was DEV only).

@gaearon gaearon merged commit a1414e8 into facebook:master Jan 21, 2019
@gaearon
Copy link
Collaborator Author

gaearon commented Jan 21, 2019

I'll merge to unblock the sync.

gaearon added a commit that referenced this pull request Jan 21, 2019
gaearon added a commit that referenced this pull request Jan 21, 2019
…Mode" (#14652)

* Revert "Revert "Disallow reading context during useMemo etc" (#14651)"

This reverts commit 5fce648.

* Revert "Add test coverage for readContext() on the server (#14649)"

This reverts commit fe2ecd2.

* Revert "Warn about incorrect use of useImperativeHandle() (#14647)"

This reverts commit 8f45a7f.

* Revert "Disallow reading context during useMemo etc (#14648)"

This reverts commit 1fcbd22.

* Revert "Warn about refs on lazy function components (#14645)"

This reverts commit 2a084f5.

* Revert "Fix typo (#14560)"

This reverts commit b5a3df6.

* Revert "fix typo (#14316)"

This reverts commit 9c146e6.

* Revert "Mention forwardRef() in <Fn ref={...} /> errors and warnings (#14644)"

This reverts commit baa6d40.

* Revert "Double-render function components with Hooks in DEV in StrictMode (#14643)"

This reverts commit a1414e8.
@bvaughn
Copy link
Contributor

bvaughn commented Jan 22, 2019

Nice compromise, Dan

@gaearon
Copy link
Collaborator Author

gaearon commented Jan 22, 2019

I already reverted

@gaearon
Copy link
Collaborator Author

gaearon commented Jan 22, 2019

(Resubmitted in #14654)

@bvaughn
Copy link
Contributor

bvaughn commented Jan 22, 2019

Hm?

This was just a follow up comment from #14639.

I just meant the concept of doing the double-rendering only for function components that used hooks. Seems like a nice compromise from double rendering everything.

@gaearon
Copy link
Collaborator Author

gaearon commented Jan 22, 2019

Just wanted to clarify we haven't actually landed this

@gaearon gaearon deleted the fun-sm-hooks branch January 22, 2019 17:06
jetoneza pushed a commit to jetoneza/react that referenced this pull request Jan 23, 2019
…cebook#14643)

* Double-render functions in strict mode

* Double-invoke first function component render too

* Mark TestRendererAsync test as internal and revert changes to it

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.

* Only double-invoke components using Hooks

* Revert unintentional change
jetoneza pushed a commit to jetoneza/react that referenced this pull request Jan 23, 2019
…Mode" (facebook#14652)

* Revert "Revert "Disallow reading context during useMemo etc" (facebook#14651)"

This reverts commit 5fce648.

* Revert "Add test coverage for readContext() on the server (facebook#14649)"

This reverts commit fe2ecd2.

* Revert "Warn about incorrect use of useImperativeHandle() (facebook#14647)"

This reverts commit 8f45a7f.

* Revert "Disallow reading context during useMemo etc (facebook#14648)"

This reverts commit 1fcbd22.

* Revert "Warn about refs on lazy function components (facebook#14645)"

This reverts commit 2a084f5.

* Revert "Fix typo (facebook#14560)"

This reverts commit b5a3df6.

* Revert "fix typo (facebook#14316)"

This reverts commit 9c146e6.

* Revert "Mention forwardRef() in <Fn ref={...} /> errors and warnings (facebook#14644)"

This reverts commit baa6d40.

* Revert "Double-render function components with Hooks in DEV in StrictMode (facebook#14643)"

This reverts commit a1414e8.
n8schloss pushed a commit to n8schloss/react that referenced this pull request Jan 31, 2019
…cebook#14643)

* Double-render functions in strict mode

* Double-invoke first function component render too

* Mark TestRendererAsync test as internal and revert changes to it

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.

* Only double-invoke components using Hooks

* Revert unintentional change
n8schloss pushed a commit to n8schloss/react that referenced this pull request Jan 31, 2019
…Mode" (facebook#14652)

* Revert "Revert "Disallow reading context during useMemo etc" (facebook#14651)"

This reverts commit 5fce648.

* Revert "Add test coverage for readContext() on the server (facebook#14649)"

This reverts commit fe2ecd2.

* Revert "Warn about incorrect use of useImperativeHandle() (facebook#14647)"

This reverts commit 8f45a7f.

* Revert "Disallow reading context during useMemo etc (facebook#14648)"

This reverts commit 1fcbd22.

* Revert "Warn about refs on lazy function components (facebook#14645)"

This reverts commit 2a084f5.

* Revert "Fix typo (facebook#14560)"

This reverts commit b5a3df6.

* Revert "fix typo (facebook#14316)"

This reverts commit 9c146e6.

* Revert "Mention forwardRef() in <Fn ref={...} /> errors and warnings (facebook#14644)"

This reverts commit baa6d40.

* Revert "Double-render function components with Hooks in DEV in StrictMode (facebook#14643)"

This reverts commit a1414e8.
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.

None yet

5 participants