Skip to content

Don't pass dependencies to Reanimated hooks on native - #4472

Merged
m-bert merged 1 commit into
mainfrom
@mbert/rea-hooks
Aug 26, 2026
Merged

Don't pass dependencies to Reanimated hooks on native#4472
m-bert merged 1 commit into
mainfrom
@mbert/rea-hooks

Conversation

@m-bert

@m-bert m-bert commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

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.

Copilot AI lite review requested due to automatic review settings August 26, 2026 08:43
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 977bf1a7-9e61-4afb-8014-4213b78b678f

📥 Commits

Reviewing files that changed from the base of the PR and between 80cfa6f and de7f456.

📒 Files selected for processing (2)
  • packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx
  • packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved drawer slide progress updates for smoother and more reliable animations.
    • Fixed swipeable component animation behavior across web and native platforms.
    • Ensured gesture-driven transitions remain synchronized during interactions.

Walkthrough

The changes update animated dependency handling in ReanimatedDrawerLayout and ReanimatedSwipeable. Drawer slide callbacks no longer use an empty dependency array. Swipeable animated styles use platform-specific dependencies.

Changes

Animated dependency handling

Layer / File(s) Summary
Drawer slide callback updates
packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx
useDerivedValue no longer receives an empty dependency array when scheduling onDrawerSlide.
Swipeable style dependencies
packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx
The animated style uses [appliedTranslation, rowState] on web and undefined on native platforms.

Merge Risk: ⚪ Minimal · up to de7f4

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)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: Reanimated hooks no longer receive dependency arrays on native platforms.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 useAnimatedStyle dependencies in ReanimatedSwipeable only on web (Platform.OS === 'web').
  • Remove the no-op empty dependency array from useDerivedValue in ReanimatedDrawerLayout.

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.

@m-bert
m-bert merged commit 7e1de71 into main Aug 26, 2026
6 checks passed
@m-bert
m-bert deleted the @mbert/rea-hooks branch August 26, 2026 09:31
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.

3 participants