-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Conversation
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:
|
Details of bundled changes.Comparing: a3bf668...8244805 react-dom
react-art
react-test-renderer
react-reconciler
react-native-renderer
ReactDOM: size: 0.0%, gzip: 0.0% Size changes (experimental) |
Details of bundled changes.Comparing: a3bf668...8244805 react-native-renderer
react-art
react-test-renderer
react-dom
react-reconciler
ReactDOM: size: 🔺+0.3%, gzip: 🔺+0.4% Size changes (stable) |
packages/react-dom/src/events/__tests__/DOMModernPluginEventSystem-test.internal.js
Outdated
Show resolved
Hide resolved
e14e5c0
to
7f2ca55
Compare
6bd450e
to
72d8aba
Compare
@trueadm you have added react-dom-16.13.0.tgz. it's a mistake? |
@ecreeth Nicly spotted. Thanks :) |
f438e45
to
f65c46c
Compare
bd161c8
to
87ed733
Compare
There was a problem hiding this 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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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.