Repository navigation
Commit 7e1de71
authored
Don't pass dependencies to Reanimated hooks on native (#4472)
## Description
Since Reanimated 4.6 (software-mansion/react-native-reanimated#10009)
the native implementations of `useAnimatedStyle`, `useDerivedValue` and
other hooks log a dev warning whenever a dependencies argument is
passed, since dependencies are only relevant on web:
```
WARN [Reanimated] dependencies should only be used in web implementation.
```
We pass dependencies in two places:
- `ReanimatedSwipeable` passes `[appliedTranslation, rowState]` to
`useAnimatedStyle`. The dependencies are still needed on web, where
bundlers resolve the compiled `lib` output that isn't processed by the
Reanimated babel plugin, so they are now passed only when `Platform.OS
=== 'web'`.
- `ReanimatedDrawerLayout` passed an empty array to `useDerivedValue`.
An empty array does nothing on any platform (the web fallback only reads
non-empty dependencies), so it's simply removed.
## Test plan
- Open the Swipeable and Drawer examples in the example app on native
and check that the warning is no longer logged.
- Check that Swipeable still animates correctly in the example app
running on web.1 parent 80cfa6f commit 7e1de71
2 files changed
Lines changed: 3 additions & 3 deletions
File tree
- packages/react-native-gesture-handler/src/components
- ReanimatedSwipeable
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
346 | | - | |
| 346 | + | |
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
640 | 640 | | |
641 | 641 | | |
642 | 642 | | |
643 | | - | |
| 643 | + | |
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| |||
0 commit comments