Commit 319fe86
authored
Lazy addition of callbacks to
## Description
Currently we call `useHandler` with all callbacks, for example:
```js
const handlers: CallbackHandlers = {
onBegin: config.onBegin,
onStart: config.onStart,
onEnd: config.onEnd,
onFinalize: config.onFinalize,
};
```
this means that if user does not pass them into config, those values will be `undefined`. This works on `android` and `iOS`, but it seems to break on `web` as Reanimated throws error that `useHandler` received non-worklet callback. To avoid potential issues, we only assign callbacks that were passed by user.
>[!WARNING]
> This solves only one issue - passing `undefined` callbacks. However, passing callback that is not marked as `worklet` will result in the same error. This problem will be handled by autoworkletization.
## Test plan
Tested with `console.logs` in event hooks.useHandler (#3674)1 parent 8e24174 commit 319fe86
3 files changed
Lines changed: 16 additions & 11 deletions
File tree
- packages/react-native-gesture-handler/src/v3/hooks/events
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
0 commit comments