Skip to content

Fix ReanimatedDrawerLayout animation speed after rerender - #4470

Merged
m-bert merged 4 commits into
software-mansion:mainfrom
ngocdevv:fix/reanimated-drawer-animation-speed-rerender
Aug 27, 2026
Merged

Fix ReanimatedDrawerLayout animation speed after rerender#4470
m-bert merged 4 commits into
software-mansion:mainfrom
ngocdevv:fix/reanimated-drawer-animation-speed-rerender

Conversation

@ngocdevv

@ngocdevv ngocdevv commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #4469.

ReanimatedDrawerLayout memoized animateDrawer without animationSpeedProp, so changing the prop did not affect later programmatic openDrawer() or closeDrawer() calls. The callback now tracks the prop and the imperative methods receive the latest default spring speed after a rerender.

Test plan

  • yarn workspace react-native-gesture-handler test --runInBand — 159 tests passed
  • yarn workspace react-native-gesture-handler ts-check
  • yarn workspace react-native-gesture-handler lint-js — no errors (existing warnings remain)
  • yarn workspace react-native-gesture-handler build

Copilot AI lite review requested due to automatic review settings August 24, 2026 15:51
@coderabbitai

coderabbitai Bot commented Aug 24, 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: 5a341412-8c61-49e1-bf5c-43c89b28a650

📥 Commits

Reviewing files that changed from the base of the PR and between b858ef8 and 73f97c3.

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

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


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Updated drawer animations to consistently reflect changes to the configured animation speed.

Walkthrough

animateDrawer now updates when animationSpeedProp changes. Programmatic drawer operations can therefore use the latest animation speed after a rerender.

Changes

Drawer animation speed

Layer / File(s) Summary
Refresh animation speed callback
packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx
The animateDrawer callback dependency list now includes animationSpeedProp.

Suggested reviewers: m-bert

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change adds animationSpeedProp to animateDrawer’s callback dependencies. This directly fixes the stale prop captured after rerender and ensures later openDrawer() and closeDrawer() calls use the l…
Out of Scope Changes check ✅ Passed The pull request changes only the relevant callback dependency in ReanimatedDrawerLayout.tsx. The change is directly related to issue #4469 and introduces no unrelated code changes.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing stale animation speed handling in ReanimatedDrawerLayout after rerenders.
Full details: Linked Issues check

Explanation

The change adds animationSpeedProp to animateDrawer’s callback dependencies. This directly fixes the stale prop captured after rerender and ensures later openDrawer() and closeDrawer() calls use the latest animation speed described in issue #4469.


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

Fixes a stale-closure bug in ReanimatedDrawerLayout where programmatic openDrawer() / closeDrawer() continued using the initial animationSpeed prop after a rerender, and adds a regression test to lock in the expected behavior.

Changes:

  • Add animationSpeedProp to animateDrawer’s useCallback dependency list so updated props are reflected in subsequent imperative calls.
  • Add a Jest regression test that verifies the computed spring mass updates after rerendering with a new animationSpeed.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx Fixes stale animationSpeed capture by tracking animationSpeedProp in animateDrawer callback deps.
packages/react-native-gesture-handler/src/tests/reanimatedDrawerLayoutAnimationSpeed.test.tsx Adds regression test asserting withSpring receives updated mass after prop-only rerender.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@m-bert m-bert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi @ngocdevv! Thank you for subimitting this PR! While this fix looks good, I don't think we need this big test file just for this specific behavior.

@m-bert
m-bert merged commit ed9410d into software-mansion:main Aug 27, 2026
5 checks passed
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.

ReanimatedDrawerLayout uses stale animationSpeed after rerender

3 participants