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: Add more scaffolding for useEvent hook #18271

Merged
merged 1 commit into from
Mar 10, 2020

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Mar 10, 2020

This PR is a follow up to #18267. Specifically, this adds a bit more of the useEvent hook implementation (but most just leaves most the code as TODOs). Furthermore, there's a very simple test that validates that the hook works in terms of returning the same event listener map.

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

codesandbox-ci bot commented Mar 10, 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 8244805:

Sandbox Source
divine-frog-10uqj Configuration

@sizebot
Copy link

sizebot commented Mar 10, 2020

Details of bundled changes.

Comparing: a3bf668...8244805

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js +0.1% +0.1% 124.39 KB 124.46 KB 38.8 KB 38.82 KB NODE_PROFILING
ReactDOM-dev.js +0.1% 0.0% 918.98 KB 920.21 KB 204.76 KB 204.84 KB FB_WWW_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% 0.0% 10.27 KB 10.27 KB 3.5 KB 3.5 KB UMD_PROD
ReactDOMServer-dev.js +0.1% +0.1% 137.64 KB 137.75 KB 35.17 KB 35.19 KB FB_WWW_DEV
ReactDOMTesting-dev.js +0.1% 0.0% 875.57 KB 876.8 KB 196.02 KB 196.11 KB FB_WWW_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 370.03 KB 370.2 KB 67.71 KB 67.74 KB FB_WWW_PROD
ReactDOMTesting-profiling.js 0.0% 0.0% 370.03 KB 370.2 KB 67.71 KB 67.74 KB FB_WWW_PROFILING
react-dom-server.node.development.js +0.1% +0.1% 131.08 KB 131.19 KB 34.83 KB 34.87 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% 0.0% 10.81 KB 10.81 KB 4.1 KB 4.1 KB NODE_PROD
react-dom-server.node.production.min.js 🔺+0.2% 🔺+0.3% 20.83 KB 20.88 KB 7.61 KB 7.63 KB NODE_PROD
react-dom.development.js +0.1% 0.0% 916.47 KB 917.79 KB 200.56 KB 200.64 KB UMD_DEV
react-dom-server.browser.development.js +0.1% +0.1% 136.87 KB 136.99 KB 34.99 KB 35.02 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 0.0% 120.27 KB 120.34 KB 38.41 KB 38.42 KB UMD_PROD
react-dom-server.browser.production.min.js 🔺+0.2% 🔺+0.1% 20.51 KB 20.56 KB 7.51 KB 7.52 KB UMD_PROD
react-dom.profiling.min.js +0.1% +0.1% 124.09 KB 124.17 KB 39.63 KB 39.65 KB UMD_PROFILING
react-dom.development.js +0.1% 0.0% 872.36 KB 873.59 KB 198.11 KB 198.2 KB NODE_DEV
react-dom-server.browser.development.js +0.1% +0.1% 129.87 KB 129.97 KB 34.58 KB 34.61 KB NODE_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 120.42 KB 120.49 KB 37.61 KB 37.63 KB NODE_PROD
react-dom-server.browser.production.min.js 🔺+0.2% 🔺+0.3% 20.43 KB 20.48 KB 7.46 KB 7.48 KB NODE_PROD
ReactDOM-prod.js 0.0% 0.0% 375.92 KB 376.09 KB 68.43 KB 68.45 KB FB_WWW_PROD
ReactDOMServer-prod.js 🔺+0.2% 🔺+0.2% 46.78 KB 46.86 KB 10.87 KB 10.89 KB FB_WWW_PROD
ReactDOM-profiling.js 0.0% 0.0% 393.18 KB 393.35 KB 71.42 KB 71.44 KB FB_WWW_PROFILING
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.16 KB 1.16 KB 662 B 663 B NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.35 KB 3.35 KB 1.27 KB 1.27 KB UMD_DEV
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.19 KB 1.19 KB 699 B 700 B UMD_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1 KB 1 KB 610 B 611 B NODE_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% 637.41 KB 638.73 KB 133.87 KB 133.97 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 107.01 KB 107.09 KB 32.35 KB 32.37 KB UMD_PROD
react-art.development.js +0.2% +0.1% 541.46 KB 542.69 KB 116.29 KB 116.38 KB NODE_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 71.99 KB 72.06 KB 21.54 KB 21.56 KB NODE_PROD
ReactART-dev.js +0.2% +0.1% 554.66 KB 555.89 KB 116.34 KB 116.43 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.1% 🔺+0.1% 226.21 KB 226.38 KB 38.55 KB 38.58 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.development.js 0.0% -0.0% 38.4 KB 38.4 KB 9.3 KB 9.3 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% 0.0% 12.92 KB 12.92 KB 3.94 KB 3.94 KB UMD_PROD
ReactTestRenderer-dev.js +0.2% +0.1% 555.01 KB 556.24 KB 117.25 KB 117.33 KB FB_WWW_DEV
react-test-renderer.development.js +0.2% +0.1% 553.96 KB 555.28 KB 115.38 KB 115.48 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 71.3 KB 71.37 KB 21.72 KB 21.75 KB UMD_PROD
react-test-renderer.development.js +0.2% +0.1% 527.93 KB 529.17 KB 114.07 KB 114.16 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 71.11 KB 71.18 KB 21.37 KB 21.39 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% 579.94 KB 581.18 KB 122.22 KB 122.31 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.1% 🔺+0.1% 76.85 KB 76.92 KB 22.55 KB 22.57 KB NODE_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 251.89 KB 252.06 KB 43.74 KB 43.76 KB RN_OSS_PROD
ReactFabric-profiling.js +0.1% +0.1% 263.69 KB 263.86 KB 46 KB 46.03 KB RN_OSS_PROFILING
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 259.93 KB 260.1 KB 45.22 KB 45.25 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 271.73 KB 271.89 KB 47.47 KB 47.5 KB RN_OSS_PROFILING
ReactNativeRenderer-dev.js +0.2% +0.1% 636.77 KB 637.99 KB 137.92 KB 138 KB RN_FB_DEV
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 260.08 KB 260.24 KB 45.25 KB 45.27 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 271.87 KB 272.03 KB 47.5 KB 47.53 KB RN_FB_PROFILING
ReactFabric-dev.js +0.2% +0.1% 616.01 KB 617.23 KB 133.25 KB 133.34 KB RN_OSS_DEV
ReactFabric-dev.js +0.2% +0.1% 618.72 KB 619.95 KB 133.58 KB 133.66 KB RN_FB_DEV
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 252.05 KB 252.21 KB 43.77 KB 43.79 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.2% +0.1% 634.06 KB 635.28 KB 137.58 KB 137.66 KB RN_OSS_DEV
ReactFabric-profiling.js +0.1% +0.1% 263.84 KB 264.01 KB 46.03 KB 46.06 KB RN_FB_PROFILING

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against 8244805

@sizebot
Copy link

sizebot commented Mar 10, 2020

Details of bundled changes.

Comparing: a3bf668...8244805

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.2% +0.1% 634.04 KB 635.27 KB 137.58 KB 137.66 KB RN_OSS_DEV
ReactNativeRenderer-prod.js 🔺+0.1% 🔺+0.1% 259.92 KB 260.08 KB 45.21 KB 45.24 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.1% +0.1% 271.71 KB 271.88 KB 47.47 KB 47.49 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.2% +0.1% 615.99 KB 617.22 KB 133.24 KB 133.33 KB RN_OSS_DEV
ReactFabric-prod.js 🔺+0.1% 🔺+0.1% 251.88 KB 252.05 KB 43.73 KB 43.75 KB RN_OSS_PROD
ReactFabric-profiling.js +0.1% +0.1% 263.68 KB 263.84 KB 45.99 KB 46.02 KB RN_OSS_PROFILING

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.2% +0.1% 521.35 KB 522.58 KB 112.55 KB 112.64 KB NODE_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 69.29 KB 69.36 KB 20.8 KB 20.82 KB NODE_PROD
ReactART-dev.js +0.2% +0.1% 582.73 KB 583.96 KB 121.96 KB 122.07 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.1% 🔺+0.1% 235.06 KB 235.23 KB 39.96 KB 39.98 KB FB_WWW_PROD
react-art.development.js +0.2% +0.1% 616.46 KB 617.78 KB 130.18 KB 130.27 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 0.0% 104.26 KB 104.33 KB 31.62 KB 31.63 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.development.js +0.2% +0.1% 527.91 KB 529.14 KB 114.06 KB 114.14 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 71.09 KB 71.16 KB 21.36 KB 21.37 KB NODE_PROD
ReactTestRenderer-dev.js +0.2% +0.1% 555 KB 556.23 KB 117.24 KB 117.33 KB FB_WWW_DEV
react-test-renderer.development.js +0.2% +0.1% 553.93 KB 555.25 KB 115.37 KB 115.47 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.1% 71.28 KB 71.35 KB 21.71 KB 21.73 KB UMD_PROD

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactDOM-profiling.js 0.0% 0.0% 419.84 KB 420.02 KB 76.16 KB 76.18 KB FB_WWW_PROFILING
react-dom-server.browser.development.js +0.1% +0.1% 135.28 KB 135.4 KB 34.79 KB 34.82 KB UMD_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.2% 1.15 KB 1.15 KB 653 B 654 B NODE_PROD
react-dom-server.browser.production.min.js 🔺+0.3% 🔺+0.4% 20.05 KB 20.1 KB 7.42 KB 7.45 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% 0.0% 55.86 KB 55.86 KB 14.46 KB 14.46 KB NODE_DEV
react-dom.development.js +0.1% 0.0% 886 KB 887.32 KB 195.32 KB 195.41 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 0.0% 116.07 KB 116.14 KB 37.17 KB 37.18 KB UMD_PROD
react-dom.profiling.min.js +0.1% +0.1% 119.78 KB 119.85 KB 38.43 KB 38.47 KB UMD_PROFILING
react-dom.development.js +0.1% 0.0% 843.17 KB 844.4 KB 192.88 KB 192.97 KB NODE_DEV
react-dom-server.node.development.js +0.1% +0.1% 129.57 KB 129.68 KB 34.61 KB 34.64 KB NODE_DEV
react-dom.production.min.js 🔺+0.1% 0.0% 116.15 KB 116.22 KB 36.52 KB 36.53 KB NODE_PROD
react-dom-server.node.production.min.js 🔺+0.2% 🔺+0.3% 20.38 KB 20.43 KB 7.53 KB 7.55 KB NODE_PROD
react-dom.profiling.min.js +0.1% +0.1% 120.01 KB 120.08 KB 37.65 KB 37.68 KB NODE_PROFILING
ReactDOM-dev.js +0.1% 0.0% 964.9 KB 966.13 KB 214.75 KB 214.83 KB FB_WWW_DEV
ReactDOM-prod.js 0.0% 0.0% 402.53 KB 402.7 KB 73.11 KB 73.14 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
ReactDOMTesting-dev.js +0.1% 0.0% 902.21 KB 903.44 KB 201.61 KB 201.7 KB FB_WWW_DEV
ReactDOMTesting-prod.js 0.0% 0.0% 383.59 KB 383.76 KB 69.88 KB 69.91 KB FB_WWW_PROD
react-dom-server.browser.development.js +0.1% +0.1% 128.35 KB 128.46 KB 34.36 KB 34.39 KB NODE_DEV
ReactDOMTesting-profiling.js 0.0% 0.0% 383.59 KB 383.76 KB 69.88 KB 69.91 KB FB_WWW_PROFILING
react-dom-server.browser.production.min.js 🔺+0.2% 🔺+0.3% 19.97 KB 20.02 KB 7.38 KB 7.4 KB NODE_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.1% 1.17 KB 1.17 KB 690 B 691 B UMD_PROD
ReactDOMServer-dev.js +0.1% +0.1% 138.5 KB 138.6 KB 35.3 KB 35.33 KB FB_WWW_DEV
react-dom-test-utils.development.js 0.0% 0.0% 49.55 KB 49.55 KB 13.51 KB 13.51 KB NODE_DEV
ReactDOMServer-prod.js 🔺+0.2% 🔺+0.2% 47.49 KB 47.57 KB 11.05 KB 11.07 KB FB_WWW_PROD
react-dom-unstable-fizz.browser.production.min.js 0.0% 🔺+0.2% 1013 B 1013 B 602 B 603 B 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% 557.5 KB 558.73 KB 118.02 KB 118.1 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.1% 🔺+0.1% 73.76 KB 73.83 KB 21.78 KB 21.81 KB NODE_PROD

ReactDOM: size: 🔺+0.3%, gzip: 🔺+0.4%

Size changes (stable)

Generated by 🚫 dangerJS against 8244805

@trueadm trueadm force-pushed the use-event-2 branch 2 times, most recently from e14e5c0 to 7f2ca55 Compare March 10, 2020 18:05
@trueadm trueadm force-pushed the use-event-2 branch 3 times, most recently from 6bd450e to 72d8aba Compare March 10, 2020 18:26
@ecreeth
Copy link

ecreeth commented Mar 10, 2020

@trueadm you have added react-dom-16.13.0.tgz. it's a mistake?

@trueadm
Copy link
Contributor Author

trueadm commented Mar 10, 2020

@ecreeth Nicly spotted. Thanks :)

@trueadm trueadm force-pushed the use-event-2 branch 3 times, most recently from f438e45 to f65c46c Compare March 10, 2020 19:18
@trueadm trueadm requested a review from acdlite March 10, 2020 19:35
@trueadm trueadm force-pushed the use-event-2 branch 3 times, most recently from bd161c8 to 87ed733 Compare March 10, 2020 20:03
Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

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

I'm a little unsure of some of the type decisions with this API since I haven't been involved in the other PRs. Looks like this change is okay though, except for the failing test stuff.

@@ -26,6 +26,10 @@ import ReactNativeFiberHostComponent from './ReactNativeFiberHostComponent';

const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;

export type ReactListenerEvent = Object;
export type ReactListenerMap = Object;
export type ReactListener = Object;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if you considered using a shared type between the reconciler and non-reconciler based renderers?

Do we expect that the type of ReactListenerMap and ReactListener will vary between renderers? I guess they would if ReactListenerEvent varied... maybe it would be hard to manage this with Flow generics.

I'm just a little concerned that Flow doesn't have our back here to keep all of the renderers in sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I considered it, but I think that will largely become something to consider once we actually add these to those renderers. Given this is only exported (for now anyway) on ReactDOM, I don't see this as a blocker. In the long-term, we'd probably expose slightly different API. Like you mention, doing this with generics can become a bit of a pain, so I wanted to keep it as Object for now, just to make this work-load easier to get into the internal testing phase.

Add test

Fix

Address feedback

fix

Fix flow types

Fix

Fix

Wtf?

Fix path

Fix

Fix bundles...

Fix CI tests, by adding to experimental build

Attempt #2 at fixing CI

Revert

Fix

Fix lint
@trueadm trueadm merged commit 160505b into facebook:master Mar 10, 2020
@trueadm trueadm deleted the use-event-2 branch March 11, 2020 14:42
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