ReactDOM.useEvent: support custom types#18351
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 84afbf1:
|
threepointone
left a comment
There was a problem hiding this comment.
approving in advance, with my usual nits
| custom = ReactDOM.unstable_useEvent('custom-event'); | ||
| }).toWarnDev( | ||
| 'Warning: The event "type" provided to useEvent() does not have a known priority type. ' + | ||
| 'It is recommended to provide a "priority" option to specify a priority.', |
There was a problem hiding this comment.
I know this is old, but it's only obvious to me now that this isn't clear. What are the possible values of priority? Where can I learn more about it? etc. In a future PR this message should be made verbose, especially if we expect people to start using custom events.
There was a problem hiding this comment.
The possible values are 0, 1, 2 – for Discrete, user blocking and continious. I think we'll need to expose them from an enum on React maybe, but right now I'm unsure how that would work.
3f19be9 to
bce8460
Compare
Address feedback Address feedback Address feedback
bce8460 to
84afbf1
Compare
* ReactDOM.useEvent: support custom types
This PR adds support for custom user events to the
useEventsystem. I've also added tests demonstrating them working as expected. I also added an unnecessaryphasedRegistrationNames == nullcheck inaccumulateTwoPhaseListenersthat never occurs at runtime. This essentially allows this: