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

Backwards compat fix for ReactCurrentDispatcher on older react versions #14770

Merged
merged 2 commits into from
Feb 6, 2019

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Feb 6, 2019

Potential fix for #14763.

Current owner and dispatcher used to share the same ref, but PR #14548 split them out to better support the react-debug-tools package. This had the unintended side effect of newer renderers incompatible with versions of the react package that predate this change.

This PR adds a fallback property.

@sizebot
Copy link

sizebot commented Feb 6, 2019

ReactDOM: size: 🔺+0.1%, gzip: 🔺+0.1%

Details of bundled changes.

Comparing: 0975ea3...6e638c9

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js 0.0% +0.1% 751.49 KB 751.85 KB 171.73 KB 171.86 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 105.03 KB 105.12 KB 33.9 KB 33.92 KB UMD_PROD
react-dom.profiling.min.js +0.1% 0.0% 107.96 KB 108.05 KB 34.77 KB 34.79 KB UMD_PROFILING
react-dom.development.js 0.0% +0.1% 746.08 KB 746.44 KB 170.22 KB 170.36 KB NODE_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 105.2 KB 105.29 KB 33.34 KB 33.37 KB NODE_PROD
react-dom.profiling.min.js +0.1% +0.1% 108.28 KB 108.37 KB 34.17 KB 34.2 KB NODE_PROFILING
ReactDOM-dev.js 0.0% +0.1% 768.74 KB 769.1 KB 171.45 KB 171.58 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 🔺+0.1% 314.52 KB 314.66 KB 57.53 KB 57.57 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% +0.1% 320.87 KB 321 KB 58.92 KB 58.95 KB FB_WWW_PROFILING
react-dom-unstable-fire.development.js 0.0% +0.1% 751.83 KB 752.19 KB 171.87 KB 172.01 KB UMD_DEV
react-dom-unstable-fire.production.min.js 🔺+0.1% 🔺+0.1% 105.05 KB 105.14 KB 33.91 KB 33.93 KB UMD_PROD
react-dom-unstable-fire.profiling.min.js +0.1% 0.0% 107.97 KB 108.06 KB 34.78 KB 34.79 KB UMD_PROFILING
react-dom-unstable-fire.development.js 0.0% +0.1% 746.43 KB 746.79 KB 170.36 KB 170.5 KB NODE_DEV
react-dom-unstable-fire.production.min.js 🔺+0.1% 🔺+0.1% 105.22 KB 105.31 KB 33.35 KB 33.38 KB NODE_PROD
react-dom-unstable-fire.profiling.min.js +0.1% +0.1% 108.29 KB 108.38 KB 34.17 KB 34.21 KB NODE_PROFILING
ReactFire-dev.js 0.0% +0.1% 767.95 KB 768.31 KB 171.37 KB 171.5 KB FB_WWW_DEV
ReactFire-prod.js 0.0% 0.0% 303.01 KB 303.14 KB 55.23 KB 55.25 KB FB_WWW_PROD
ReactFire-profiling.js 0.0% 0.0% 309.38 KB 309.51 KB 56.61 KB 56.64 KB FB_WWW_PROFILING
react-dom-test-utils.development.js +0.8% +1.1% 46.16 KB 46.52 KB 12.69 KB 12.84 KB UMD_DEV
react-dom-test-utils.production.min.js 🔺+1.4% 🔺+1.1% 10.11 KB 10.25 KB 3.74 KB 3.79 KB UMD_PROD
react-dom-test-utils.development.js +0.8% +1.1% 45.88 KB 46.24 KB 12.63 KB 12.77 KB NODE_DEV
react-dom-test-utils.production.min.js 🔺+1.5% 🔺+1.1% 9.89 KB 10.03 KB 3.68 KB 3.72 KB NODE_PROD
ReactTestUtils-dev.js +0.8% +1.2% 42.72 KB 43.08 KB 11.56 KB 11.7 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 11.01 KB 11.01 KB 3.81 KB 3.81 KB UMD_PROD
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.75 KB 10.75 KB 3.71 KB 3.71 KB NODE_PROD
react-dom-server.browser.development.js +0.3% +0.4% 125.66 KB 126.02 KB 33.56 KB 33.69 KB UMD_DEV
react-dom-server.browser.production.min.js 🔺+0.5% 🔺+0.3% 18.57 KB 18.66 KB 7.17 KB 7.18 KB UMD_PROD
react-dom-server.browser.development.js +0.3% +0.4% 121.79 KB 122.15 KB 32.62 KB 32.76 KB NODE_DEV
react-dom-server.browser.production.min.js 🔺+0.5% 🔺+0.3% 18.49 KB 18.58 KB 7.15 KB 7.17 KB NODE_PROD
ReactDOMServer-dev.js +0.3% +0.4% 122.77 KB 123.13 KB 32.13 KB 32.27 KB FB_WWW_DEV
ReactDOMServer-prod.js 🔺+0.3% 🔺+0.2% 44.65 KB 44.78 KB 10.34 KB 10.36 KB FB_WWW_PROD
react-dom-server.node.development.js +0.3% +0.4% 123.85 KB 124.21 KB 33.17 KB 33.3 KB NODE_DEV
react-dom-server.node.production.min.js 🔺+0.5% 🔺+0.3% 19.36 KB 19.45 KB 7.45 KB 7.48 KB NODE_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-unstable-fizz.node.production.min.js 0.0% -0.1% 1.1 KB 1.1 KB 668 B 667 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.1% 530.74 KB 531.1 KB 115.45 KB 115.58 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 0.0% 97.09 KB 97.18 KB 29.82 KB 29.83 KB UMD_PROD
react-art.development.js +0.1% +0.1% 461.75 KB 462.11 KB 98.24 KB 98.38 KB NODE_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 62.14 KB 62.23 KB 18.99 KB 19.01 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 470.79 KB 471.15 KB 97.58 KB 97.72 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.1% 🔺+0.1% 189.73 KB 189.86 KB 32.22 KB 32.26 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.1% +0.1% 595.35 KB 595.71 KB 127.88 KB 128.02 KB RN_FB_DEV
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 245.88 KB 246.01 KB 42.92 KB 42.94 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 252.17 KB 252.3 KB 44.44 KB 44.47 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.1% +0.1% 595.27 KB 595.63 KB 127.84 KB 127.98 KB RN_OSS_DEV
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 245.9 KB 246.03 KB 42.91 KB 42.93 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 252.19 KB 252.32 KB 44.43 KB 44.46 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.1% +0.1% 586.21 KB 586.57 KB 125.61 KB 125.75 KB RN_FB_DEV
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 238.35 KB 238.48 KB 41.46 KB 41.5 KB RN_FB_PROD
ReactFabric-profiling.js +0.1% +0.1% 244.52 KB 244.65 KB 42.97 KB 43.01 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% +0.1% 586.11 KB 586.47 KB 125.58 KB 125.71 KB RN_OSS_DEV
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 238.36 KB 238.49 KB 41.45 KB 41.49 KB RN_OSS_PROD
ReactFabric-profiling.js +0.1% +0.1% 244.53 KB 244.66 KB 42.97 KB 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.1% +0.1% 473.83 KB 474.19 KB 100.63 KB 100.76 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 63.49 KB 63.58 KB 19.45 KB 19.46 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 468.27 KB 468.63 KB 99.3 KB 99.45 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 63.17 KB 63.26 KB 19.13 KB 19.16 KB NODE_PROD
ReactTestRenderer-dev.js +0.1% +0.2% 477.98 KB 478.33 KB 98.96 KB 99.11 KB FB_WWW_DEV
react-test-renderer-shallow.development.js +1.0% +1.4% 36.84 KB 37.2 KB 9.38 KB 9.5 KB UMD_DEV
react-test-renderer-shallow.production.min.js 🔺+0.8% 🔺+0.6% 11.03 KB 11.12 KB 3.33 KB 3.35 KB UMD_PROD
react-test-renderer-shallow.development.js +1.2% +1.7% 31.14 KB 31.5 KB 8 KB 8.14 KB NODE_DEV
react-test-renderer-shallow.production.min.js 🔺+0.8% 🔺+0.6% 11.68 KB 11.77 KB 3.63 KB 3.66 KB NODE_PROD
ReactShallowRenderer-dev.js +1.2% +1.8% 29.55 KB 29.91 KB 7.43 KB 7.57 KB FB_WWW_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.1% +0.1% 458.77 KB 459.13 KB 96.58 KB 96.73 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.1% 🔺+0.1% 63.35 KB 63.44 KB 18.77 KB 18.79 KB NODE_PROD
react-reconciler-persistent.development.js +0.1% +0.2% 457.15 KB 457.51 KB 95.94 KB 96.08 KB NODE_DEV
react-reconciler-persistent.production.min.js 🔺+0.1% 🔺+0.1% 63.36 KB 63.45 KB 18.77 KB 18.8 KB NODE_PROD
react-reconciler-reflection.development.js +2.3% +3.0% 15.4 KB 15.76 KB 4.83 KB 4.98 KB NODE_DEV
react-reconciler-reflection.production.min.js 🔺+5.5% 🔺+8.1% 2.56 KB 2.7 KB 1.13 KB 1.23 KB NODE_PROD

react-debug-tools

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-debug-tools.development.js +2.0% +2.0% 18.23 KB 18.59 KB 5.4 KB 5.51 KB NODE_DEV
react-debug-tools.production.min.js 🔺+1.6% 🔺+0.7% 5.58 KB 5.67 KB 2.28 KB 2.3 KB NODE_PROD

Generated by 🚫 dangerJS

// but PR #14548 split them out to better support the react-debug-tools package.
if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
const {ReactCurrentOwner} = ReactSharedInternals;
ReactSharedInternals.ReactCurrentDispatcher = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't this just be {current: null}? Why does it need to forward to the owner object?

Copy link
Contributor Author

@bvaughn bvaughn Feb 6, 2019

Choose a reason for hiding this comment

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

Because I wasn't convinced that no 16.8+ renderer would ever have a valid use case for accessing current dispatcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

e.g. react-cache uses it

@bvaughn
Copy link
Contributor Author

bvaughn commented Feb 6, 2019

Okay, I've replaced the forwarding getter/setter with current: null

@bvaughn bvaughn merged commit f2e2637 into facebook:master Feb 6, 2019
@bvaughn bvaughn deleted the current-owner-ref branch February 6, 2019 17:02
@bvaughn
Copy link
Contributor Author

bvaughn commented Feb 6, 2019

We'll publish a bugfix release with this fix shortly

@fresonn
Copy link

fresonn commented Feb 6, 2019

Goddamn!

@dzienisz
Copy link

dzienisz commented Feb 6, 2019

@bvaughn do you think that this fix wouldn't happen if we could just test software a little bit more?

@gaearon
Copy link
Collaborator

gaearon commented Feb 6, 2019

I’m not sure if you’re genuinely asking or implying we didn’t test React. We spent weeks ironing out remaining issues in this release and at some point you just gotta publish. (You were welcome to try alphas which have been available for months, and the latest one had the same issue.)

We’ll keep this particular situation in mind for the future (mismatching versions of React and ReactDOM). But we’re also humans and can make mistakes. If you don’t want our mistakes to break your code then you should be using lockfiles in a production environment.

@facebook facebook locked as resolved and limited conversation to collaborators Feb 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants