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

ReactDOM.useEvent: revert and add guard for null stateNode #18441

Merged
merged 2 commits into from
Apr 1, 2020

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Mar 31, 2020

This PR reverts the revert PR (#18438) and applies the appropiate fix. The previous problem was that we were trying to call getListenersFromTarget on the instance, which was taken from node.stateNode. I missed the case where the stateNode can be null (when the component gets unmounted), so we should make sure to check that the instance is not null. I also added some validation to ensure that lastHostComponent should never be null too, as per comments from @gaearon in #18375.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Mar 31, 2020
@codesandbox-ci
Copy link

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 dc6518e:

Sandbox Source
kind-edison-j209y Configuration

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 31, 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 2d01aae:

Sandbox Source
peaceful-cherry-ckls8 Configuration

@sizebot
Copy link

sizebot commented Mar 31, 2020

Warnings
⚠️ Failed to fetch build artifacts for base commit: 90e90ac

Size changes (experimental)

Generated by 🚫 dangerJS against 2d01aae

@sizebot
Copy link

sizebot commented Mar 31, 2020

Details of bundled changes.

Comparing: 90e90ac...2d01aae

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.production.min.js 0.0% 0.0% 118.78 KB 118.81 KB 37.33 KB 37.34 KB NODE_PROD
react-dom-test-utils.development.js 0.0% -0.0% 59.23 KB 59.23 KB 15.64 KB 15.64 KB UMD_DEV
ReactDOMTesting-profiling.js +3.3% +3.1% 393.25 KB 406.21 KB 71.5 KB 73.74 KB FB_WWW_PROFILING
react-dom-unstable-fizz.browser.development.js 0.0% +0.2% 3.34 KB 3.34 KB 1.26 KB 1.26 KB UMD_DEV
react-dom.profiling.min.js 0.0% 0.0% 122.64 KB 122.67 KB 38.52 KB 38.53 KB NODE_PROFILING
react-dom-test-utils.production.min.js 0.0% -0.0% 12.25 KB 12.25 KB 4.54 KB 4.54 KB UMD_PROD
react-dom-server.node.development.js 0.0% 0.0% 127.61 KB 127.61 KB 34.13 KB 34.13 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 20.03 KB 20.03 KB 7.44 KB 7.44 KB NODE_PROD
ReactDOMForked-dev.js +2.0% +1.8% 976.52 KB 995.86 KB 217.58 KB 221.57 KB FB_WWW_DEV
ReactDOMForked-prod.js 🔺+3.2% 🔺+3.1% 408.83 KB 422 KB 73.88 KB 76.17 KB FB_WWW_PROD
react-dom-unstable-fizz.node.development.js 0.0% +0.1% 3.68 KB 3.68 KB 1.33 KB 1.33 KB NODE_DEV
react-dom.development.js 0.0% 0.0% 895.43 KB 895.45 KB 197.32 KB 197.32 KB UMD_DEV
ReactDOMForked-profiling.js +3.1% +3.0% 420.38 KB 433.55 KB 75.84 KB 78.1 KB FB_WWW_PROFILING
react-dom.production.min.js 0.0% 0.0% 118.71 KB 118.74 KB 38.11 KB 38.13 KB UMD_PROD
react-dom-server.browser.production.min.js 0.0% 0.0% 19.71 KB 19.71 KB 7.33 KB 7.34 KB UMD_PROD
react-dom.profiling.min.js 0.0% +0.1% 122.43 KB 122.45 KB 39.33 KB 39.36 KB UMD_PROFILING
ReactDOMTesting-dev.js +2.1% +2.1% 927.34 KB 947.07 KB 207.13 KB 211.49 KB FB_WWW_DEV
react-dom.development.js 0.0% 0.0% 852.48 KB 852.5 KB 194.89 KB 194.89 KB NODE_DEV
ReactDOMTesting-prod.js 🔺+3.3% 🔺+3.1% 393.25 KB 406.21 KB 71.5 KB 73.74 KB FB_WWW_PROD
ReactDOM-dev.js +2.0% +1.8% 976.52 KB 995.86 KB 217.58 KB 221.57 KB FB_WWW_DEV
ReactDOMServer-dev.js 0.0% -0.0% 136.32 KB 136.32 KB 34.74 KB 34.74 KB FB_WWW_DEV
ReactDOM-prod.js 🔺+3.2% 🔺+3.1% 408.83 KB 422 KB 73.88 KB 76.17 KB FB_WWW_PROD
react-dom-test-utils.development.js 0.0% -0.0% 54.69 KB 54.69 KB 15.03 KB 15.03 KB NODE_DEV
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 2.94 KB 2.94 KB 1.17 KB 1.17 KB NODE_DEV
ReactDOM-profiling.js +3.1% +3.0% 420.38 KB 433.55 KB 75.84 KB 78.1 KB FB_WWW_PROFILING
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 57.7 KB 57.7 KB 14.36 KB 14.36 KB UMD_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 54.71 KB 54.71 KB 14.13 KB 14.13 KB NODE_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js 0.0% -0.0% 528.32 KB 528.32 KB 114.02 KB 114.02 KB NODE_DEV
ReactART-dev.js +0.8% +0.9% 589.45 KB 594.4 KB 123.65 KB 124.77 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.2% 🔺+0.2% 250.97 KB 251.44 KB 42.5 KB 42.57 KB FB_WWW_PROD
react-art.development.js 0.0% -0.0% 623.48 KB 623.48 KB 131.72 KB 131.72 KB UMD_DEV
react-art.production.min.js 0.0% -0.0% 106.66 KB 106.66 KB 32.38 KB 32.38 KB UMD_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer-shallow.development.js 0.0% -0.0% 38.39 KB 38.39 KB 9.29 KB 9.29 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.91 KB 12.91 KB 3.94 KB 3.93 KB UMD_PROD
react-test-renderer.production.min.js 0.0% -0.0% 73.5 KB 73.5 KB 22.18 KB 22.18 KB NODE_PROD
ReactTestRenderer-dev.js +0.9% +1.0% 562.75 KB 567.77 KB 118.83 KB 119.99 KB FB_WWW_DEV
react-test-renderer.development.js 0.0% -0.0% 561.31 KB 561.31 KB 116.91 KB 116.91 KB UMD_DEV
react-test-renderer.production.min.js 0.0% -0.0% 73.68 KB 73.68 KB 22.46 KB 22.46 KB UMD_PROD

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

Size changes (stable)

Generated by 🚫 dangerJS against 2d01aae

@gaearon
Copy link
Collaborator

gaearon commented Mar 31, 2020

Thanks. Could you go through all code behind useEvent flag to search for similar bugs?

@trueadm
Copy link
Contributor Author

trueadm commented Mar 31, 2020

@gaearon I deep a deep dive earlier today, I couldn't see anywhere else we access stateNode in relation to useEvent.

Add accumulateUseEventListeners flag

Fix

Fxi

Add support for HostText being target

Fix

Remove last part

Fix

Fix
Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

lgtmbbq

@trueadm trueadm merged commit dc3c6c9 into facebook:master Apr 1, 2020
@trueadm trueadm deleted the fix-use-event branch April 1, 2020 11:45
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.

5 participants