Don't pass dependencies to Reanimated hooks on native - #4472
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes update animated dependency handling in ChangesAnimated dependency handling
Merge Risk: ⚪ Minimal · up to This change limits Reanimated hook dependencies to web where they are needed and removes an unused dependency argument on native, eliminating development warnings without introducing an actionable merge-blocking risk. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates Reanimated-based components to avoid passing dependency arrays to Reanimated hooks on native platforms, preventing the dev warning introduced in Reanimated 4.6+ while preserving required behavior on web.
Changes:
- Pass
useAnimatedStyledependencies inReanimatedSwipeableonly on web (Platform.OS === 'web'). - Remove the no-op empty dependency array from
useDerivedValueinReanimatedDrawerLayout.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx | Gates useAnimatedStyle dependencies to web-only to avoid native warnings. |
| packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx | Removes empty dependency array from useDerivedValue to avoid native warnings and simplify usage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Description
Since Reanimated 4.6 (software-mansion/react-native-reanimated#10009) the native implementations of
useAnimatedStyle,useDerivedValueand other hooks log a dev warning whenever a dependencies argument is passed, since dependencies are only relevant on web:We pass dependencies in two places:
ReanimatedSwipeablepasses[appliedTranslation, rowState]touseAnimatedStyle. The dependencies are still needed on web, where bundlers resolve the compiledliboutput that isn't processed by the Reanimated babel plugin, so they are now passed only whenPlatform.OS === 'web'.ReanimatedDrawerLayoutpassed an empty array touseDerivedValue. An empty array does nothing on any platform (the web fallback only reads non-empty dependencies), so it's simply removed.Test plan