-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Introduce useEventListener
hook
#32027
Conversation
5adb8f2
to
1666ee6
Compare
1666ee6
to
4f500f6
Compare
Subscribed to pull request
Generated by CodeMention |
📘 Your docs preview website is ready! |
@@ -15,7 +15,7 @@ | |||
- Add initial version of DOM Components and `expo/dom` module. ([#30938](https://github.com/expo/expo/pull/30938) by [@EvanBacon](https://github.com/EvanBacon)) | |||
- Support `URL.canParse`. ([#30697](https://github.com/expo/expo/pull/30697) by [@EvanBacon](https://github.com/EvanBacon)) | |||
- Add minimal `TextDecoder` support to native client platforms. ([#29620](https://github.com/expo/expo/pull/29620) by [@EvanBacon](https://github.com/EvanBacon)) | |||
- Introduced `useEvent` hook for EventEmitter objects (e.g. native modules and shared objects). ([#29056](https://github.com/expo/expo/pull/29056) by [@tsapeta](https://github.com/tsapeta)) | |||
- Introduced `useEvent` and `useEventListener` hooks for EventEmitter objects (e.g. native modules and shared objects). ([#29056](https://github.com/expo/expo/pull/29056), [#32027](https://github.com/expo/expo/pull/32027) by [@tsapeta](https://github.com/tsapeta)) |
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.
🤨 Why not a new changelog entry?
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 just thought that since the useEvent
hasn't been published yet, I can merge them as they are related. It seems better for someone who reads the changelog.
Why
useEvent
is sometimes not enough, especially when the event has no payload or we don't want to use the payload as a component's state but just react to the event.How
Introduced
useEventListener
hook, as an alternative version. Also,useEvent
will now use it under the hood.Test Plan
useEvent
usages in NCL (onlyexpo-video
right now) work as expecteduseEffect
that adds and removes the listener with the newuseEventListener