-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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 useEvent
hook
#29056
Introduce useEvent
hook
#29056
Conversation
The Pull Request introduced fingerprint changes against the base commit: e7b39a6 Fingerprint diff[
{
"type": "dir",
"filePath": "../../node_modules/expo",
"reasons": [
"bareRncliAutolinking"
],
"hash": "5bc95746701dc74a84664312463960bb73983a8c"
},
{
"type": "dir",
"filePath": "../../packages/expo",
"reasons": [
"expoAutolinkingIos",
"expoAutolinkingAndroid",
"expoConfigPlugins",
"expoConfigPlugins"
],
"hash": "79e5c7ae52bdaf04773a91f31206e2048a36bc6f"
},
{
"type": "dir",
"filePath": "../../packages/expo-modules-core",
"reasons": [
"expoAutolinkingIos",
"expoAutolinkingAndroid"
],
"hash": "b4603b8089e9877f1b2b7894d03bdf3d443e1b85"
}
] Generated by PR labeler 🤖 |
6775404
to
eabc46a
Compare
Is the hook intended to standardise existing event listener hooks, such as |
@reichhartd In the long-term, yes. For now the main purpose is to provide an API for hooks that will be used in shared objects, e.g. the video player from |
@tsapeta Yep, sounds good and makes sense to replace the custom listener wrappers with a standardised method. |
eabc46a
to
f102cfd
Compare
f102cfd
to
6af2fc4
Compare
6af2fc4
to
1bca274
Compare
📘 Your docs preview website is ready! |
Co-authored-by: Bartosz Kaszubowski <gosimek@gmail.com>
Co-authored-by: Aman Mittal <amandeepmittal@live.com>
Why
Introducing a hook that fires on event emitter's (e.g. native modules and shared objects) events and returns the event object of the most recently emitted event (or the initial value).
How
Added
useEvent
hook that usesaddListener
under the hood and re-renders whenever a new event comes in.Test Plan
I tried to use the hook and the video player object and the event payload is property typed 👇 and updates whenever the source changes.