Skip to content

Add useComposedEventHandler hook#5890

Merged
szydlovsky merged 37 commits intomainfrom
@szydlovsky/composeHandlers/hook
May 14, 2024
Merged

Add useComposedEventHandler hook#5890
szydlovsky merged 37 commits intomainfrom
@szydlovsky/composeHandlers/hook

Conversation

@szydlovsky
Copy link
Contributor

@szydlovsky szydlovsky commented Apr 11, 2024

Summary

There have already been some requests for a way to merge our event handlers. Inspired by #5854, I created a hook that can work with any handlers made using useEvent. I will happily accept any comments and suggestions regarding typing since I am not so sure about it.

composeExample.mov

The PR can be merged only ater #5845 (it is also based on it).

Test plan

Open useComposedEventHandler example from Example app and watch event callbacks in console.

@szydlovsky szydlovsky force-pushed the @szydlovsky/composeHandlers/hook branch from a7b3a18 to 41ec161 Compare April 11, 2024 13:51
@tjzel tjzel changed the base branch from main to @szydlovsky/WorkletEventHandler-revamp April 15, 2024 12:28
Copy link
Collaborator

@tjzel tjzel left a comment

Choose a reason for hiding this comment

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

Haven't read the example yet, but there are a few steps that should land in this PR.

  1. TypeScript tests. Since this is a new hook, we should come-up with some example usages and see if they don't generate TS errors for the users. See current TypeScript tests for reference.

  2. Docs page. It should be a standard to ship relevant documentation for new features ASAP. Since this is a relatively small PR I see no reason not to include it here.

@szydlovsky szydlovsky changed the title Add useComposedEventHandler hook Add useComposedEventHandler hook Apr 16, 2024
@szydlovsky szydlovsky requested a review from tjzel May 10, 2024 13:48
Copy link
Collaborator

@tjzel tjzel left a comment

Choose a reason for hiding this comment

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

Just needs some final touches.

@szydlovsky szydlovsky requested a review from tjzel May 14, 2024 09:05
Copy link
Collaborator

@tjzel tjzel left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

Copy link
Member

@piaskowyk piaskowyk left a comment

Choose a reason for hiding this comment

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

👏

@szydlovsky szydlovsky added this pull request to the merge queue May 14, 2024
Merged via the queue into main with commit 88542d6 May 14, 2024
@szydlovsky szydlovsky deleted the @szydlovsky/composeHandlers/hook branch May 14, 2024 15:03
renovate bot referenced this pull request in GSTJ/react-native-magic-modal Jun 3, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[react-native-reanimated](https://github.com/software-mansion/react-native-reanimated)
| [`~3.11.0` ->
`~3.12.0`](https://renovatebot.com/diffs/npm/react-native-reanimated/3.11.0/3.12.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/react-native-reanimated/3.12.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-native-reanimated/3.12.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-native-reanimated/3.11.0/3.12.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-native-reanimated/3.11.0/3.12.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>software-mansion/react-native-reanimated
(react-native-reanimated)</summary>

###
[`v3.12.0`](https://github.com/software-mansion/react-native-reanimated/releases/tag/3.12.0)

[Compare
Source](https://github.com/software-mansion/react-native-reanimated/compare/3.11.0...3.12.0)

#### What's Changed

- Give more meaningful warning when modifying a Shareable by
[@&#8203;tjzel](https://github.com/tjzel) in
[https://github.com/software-mansion/react-native-reanimated/pull/5548](https://github.com/software-mansion/react-native-reanimated/pull/5548)
- Make animated components use different tags for events by
[@&#8203;szydlovsky](https://github.com/szydlovsky) in
[https://github.com/software-mansion/react-native-reanimated/pull/5960](https://github.com/software-mansion/react-native-reanimated/pull/5960)
- Add `warning` and `failing` test decorators by
[@&#8203;Latropos](https://github.com/Latropos) in
[https://github.com/software-mansion/react-native-reanimated/pull/5929](https://github.com/software-mansion/react-native-reanimated/pull/5929)
- Update useAnimatedKeyboard docs by
[@&#8203;maciekstosio](https://github.com/maciekstosio) in
[https://github.com/software-mansion/react-native-reanimated/pull/5866](https://github.com/software-mansion/react-native-reanimated/pull/5866)
- Change the docs to mention, that `.springify()` works with
`.duration()` by [@&#8203;Latropos](https://github.com/Latropos) in
[https://github.com/software-mansion/react-native-reanimated/pull/5990](https://github.com/software-mansion/react-native-reanimated/pull/5990)
- \[Android]\[Keyboard] More consistent inequality check to compute
keyboard state by [@&#8203;antFrancon](https://github.com/antFrancon)
in
[https://github.com/software-mansion/react-native-reanimated/pull/5874](https://github.com/software-mansion/react-native-reanimated/pull/5874)
- fix typo on object key for `targetValues` in custom-animations.mdx by
[@&#8203;JDMathew](https://github.com/JDMathew) in
[https://github.com/software-mansion/react-native-reanimated/pull/5994](https://github.com/software-mansion/react-native-reanimated/pull/5994)
- Remove outdated code for unsupported React Native versions by
[@&#8203;tomekzaw](https://github.com/tomekzaw) in
[https://github.com/software-mansion/react-native-reanimated/pull/5979](https://github.com/software-mansion/react-native-reanimated/pull/5979)
- Remove REAInitializer by
[@&#8203;tomekzaw](https://github.com/tomekzaw) in
[https://github.com/software-mansion/react-native-reanimated/pull/5681](https://github.com/software-mansion/react-native-reanimated/pull/5681)
- Prevent crash on non-existent view updates in Android by
[@&#8203;thomas-rx](https://github.com/thomas-rx) in
[https://github.com/software-mansion/react-native-reanimated/pull/5767](https://github.com/software-mansion/react-native-reanimated/pull/5767)
- Fix location after shared element transition by
[@&#8203;piaskowyk](https://github.com/piaskowyk) in
[https://github.com/software-mansion/react-native-reanimated/pull/6010](https://github.com/software-mansion/react-native-reanimated/pull/6010)
- Make `useScrollviewOffset` ref nullable and simplify its code by
[@&#8203;szydlovsky](https://github.com/szydlovsky) in
[https://github.com/software-mansion/react-native-reanimated/pull/6009](https://github.com/software-mansion/react-native-reanimated/pull/6009)
- fix: use proper classes for bridgeless by
[@&#8203;WoLewicki](https://github.com/WoLewicki) in
[https://github.com/software-mansion/react-native-reanimated/pull/5997](https://github.com/software-mansion/react-native-reanimated/pull/5997)
- docs: add
[@&#8203;swmansion/t-rex-ui](https://github.com/swmansion/t-rex-ui) by
[@&#8203;patrycjakalinska](https://github.com/patrycjakalinska) in
[https://github.com/software-mansion/react-native-reanimated/pull/6015](https://github.com/software-mansion/react-native-reanimated/pull/6015)
- Remove `CellRendererComponent` from Animated.FlatList props by
[@&#8203;Latropos](https://github.com/Latropos) in
[https://github.com/software-mansion/react-native-reanimated/pull/5951](https://github.com/software-mansion/react-native-reanimated/pull/5951)
- Add `useComposedEventHandler` hook by
[@&#8203;szydlovsky](https://github.com/szydlovsky) in
[https://github.com/software-mansion/react-native-reanimated/pull/5890](https://github.com/software-mansion/react-native-reanimated/pull/5890)
- Align handling colors with RN by
[@&#8203;maciekstosio](https://github.com/maciekstosio) in
[https://github.com/software-mansion/react-native-reanimated/pull/5825](https://github.com/software-mansion/react-native-reanimated/pull/5825)
- Add more tests - useSharedValue, useAnimatedStyle , useDerivedValue by
[@&#8203;Latropos](https://github.com/Latropos) in
[https://github.com/software-mansion/react-native-reanimated/pull/5981](https://github.com/software-mansion/react-native-reanimated/pull/5981)
- Make animation RollInLeft work with modifers by
[@&#8203;Latropos](https://github.com/Latropos) in
[https://github.com/software-mansion/react-native-reanimated/pull/6039](https://github.com/software-mansion/react-native-reanimated/pull/6039)
- Test predefined entering animation by
[@&#8203;Latropos](https://github.com/Latropos) in
[https://github.com/software-mansion/react-native-reanimated/pull/5995](https://github.com/software-mansion/react-native-reanimated/pull/5995)
- Tests: cancelAnimation, useFrameCallback, measure, withDecay by
[@&#8203;Latropos](https://github.com/Latropos) in
[https://github.com/software-mansion/react-native-reanimated/pull/6016](https://github.com/software-mansion/react-native-reanimated/pull/6016)
- docs: fix useAnimatedKeyboard page crash by
[@&#8203;patrycjakalinska](https://github.com/patrycjakalinska) in
[https://github.com/software-mansion/react-native-reanimated/pull/6056](https://github.com/software-mansion/react-native-reanimated/pull/6056)
- \[Web LA] Remove `existingTransform` by
[@&#8203;m-bert](https://github.com/m-bert) in
[https://github.com/software-mansion/react-native-reanimated/pull/6060](https://github.com/software-mansion/react-native-reanimated/pull/6060)

#### New Contributors

[@&#8203;antFrancon](https://github.com/antFrancon),
[@&#8203;JDMathew](https://github.com/JDMathew),
[@&#8203;thomas-rx](https://github.com/thomas-rx),
[@&#8203;exploIF](https://github.com/exploIF)

#### 🙌 Thank you for your contributions!

**Full Changelog**:
software-mansion/react-native-reanimated@3.11.0...3.12.0

Package build:
https://github.com/software-mansion/react-native-reanimated/actions/runs/9287839734

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/GSTJ/react-native-magic-modal).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM3Ny44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants