Skip to content

chore: update deprecated Reanimated API use with Worklets - #4407

Merged
tjzel merged 5 commits into
@tjzel/drop-in-workletsfrom
@tjzel/worklet-api
Aug 10, 2026
Merged

chore: update deprecated Reanimated API use with Worklets#4407
tjzel merged 5 commits into
@tjzel/drop-in-workletsfrom
@tjzel/worklet-api

Conversation

@tjzel

@tjzel tjzel commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

🚀

Test plan

🚀

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 5bee5d06-4ddf-4d69-b4ca-a0adb0465c70

📥 Commits

Reviewing files that changed from the base of the PR and between f5b45f6 and e4ec9d2.

📒 Files selected for processing (2)
  • packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts
  • packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts
  • packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Updated drawer, swipe, gesture, and responder interactions to use modern worklet scheduling APIs.
    • Improved compatibility with current React Native animation and worklet runtimes.
    • Updated shared-value listener setup, cleanup, and callback scheduling.
    • Removed reliance on deprecated runtime helpers while preserving existing gesture behavior.
    • Improved coordination between UI and JavaScript threads across gesture callbacks and state updates.
    • Enhanced reliability when synchronizing gesture state, drawer actions, and swipe callbacks.

Walkthrough

The change migrates gesture components and hooks from legacy Reanimated scheduling APIs to react-native-worklets. It updates runtime contracts, shared-value handling, callbacks, worklet detection, and patched package references.

Changes

Worklets scheduling migration

Layer / File(s) Summary
Update runtime contracts
packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts, apps/*/package.json, packages/react-native-gesture-handler/package.json
The runtime contract now requires Worklets scheduling and detection APIs. Legacy Reanimated bridge members are removed. Worklets dependencies use patched package references.
Migrate gesture components
packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx, packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx
Drawer and swipeable callbacks, UI work, listener management, and imperative methods now use Worklets scheduling and runtime APIs.
Migrate hook scheduling
packages/react-native-gesture-handler/src/v3/hooks/...
Event-handler, JS responder, and shared-value utilities now use Worklets availability checks and direct UI/RN scheduling APIs.

Sequence Diagram(s)

sequenceDiagram
  participant GestureComponents
  participant Worklets
  participant ReactNativeRuntime
  GestureComponents->>Worklets: scheduleOnUI(worklet)
  Worklets->>GestureComponents: Attach or remove shared-value listener
  GestureComponents->>Worklets: scheduleOnRN(callback)
  Worklets->>ReactNativeRuntime: Execute callback
Loading

Possibly related PRs

Suggested reviewers: j-piasecki, m-bert

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes replacing deprecated Reanimated API usage with Worklets APIs.
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 review requested due to automatic review settings August 7, 2026 15:17

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 the v3 hooks and Reanimated-based components to stop using deprecated react-native-reanimated APIs (runOnUI / runOnJS) and instead route UI/RN scheduling through Worklets (scheduleOnUI / scheduleOnRN) via the library’s wrapper and (in some components) direct react-native-worklets imports.

Changes:

  • Replaced Reanimated.runOnUI usage in v3 hook utilities with Worklets.scheduleOnUI.
  • Updated JS responder / event handler hooks to use Worklets scheduling and Worklet-based worklet detection.
  • Migrated ReanimatedSwipeable and ReanimatedDrawerLayout from runOnJS/runOnUI/_WORKLET to react-native-worklets helpers.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/react-native-gesture-handler/src/v3/hooks/utils/reanimatedUtils.ts Switches shared-value listener binding/unbinding from runOnUI to Worklets.scheduleOnUI.
packages/react-native-gesture-handler/src/v3/hooks/useJSResponderHandler.ts Uses Worklets scheduling to attach/detach shared-value listeners and notify JS.
packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts Uses Worklets for worklet detection, shareable map creation, and UI cleanup scheduling.
packages/react-native-gesture-handler/src/handlers/gestures/reanimatedWrapper.ts Updates wrapper typings around Worklets/Reanimated and removes deprecated Reanimated helpers from the type surface.
packages/react-native-gesture-handler/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx Migrates Swipeable scheduling/“worklet runtime” checks to react-native-worklets.
packages/react-native-gesture-handler/src/components/ReanimatedDrawerLayout.tsx Migrates DrawerLayout callback scheduling to react-native-worklets.
packages/react-native-gesture-handler/src/tests/runOnJSReanimatedHandlers.test.tsx Updates the Reanimated wrapper mock to reflect removed deprecated APIs.
Suppressed comments (1)

packages/react-native-gesture-handler/src/v3/hooks/callbacks/useReanimatedEventHandler.ts:86

  • When Worklets is undefined, Worklets?.isWorkletFunction(...) evaluates to undefined, so this condition becomes true and onUpdate is replaced with workletNOOP even if the user provided a real worklet. That effectively disables onUpdate handling whenever react-native-worklets isn't available.
    if (!Worklets?.isWorkletFunction(handlers.onUpdate)) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@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.

Changes look ok, please merge base branch - for now web doesn't work 😞

Comment thread .yarn/patches/react-native-worklets-npm-0.9.1-5bc5b900ed.patch
@tjzel
tjzel merged commit 4e05838 into main Aug 10, 2026
11 checks passed
@tjzel
tjzel deleted the @tjzel/worklet-api branch August 10, 2026 08:33
m-bert added a commit that referenced this pull request Aug 10, 2026
## Description

#4407 stack upgraded Worklets to 0.9. The problem is that Worklets 0.9
require Reanimated 4.4 or newer. These Rea versions do not support RN
0.81, which is still the latest release of `react-native-macos`. We
decided to downgrade worklets instead of trying to revive RN Macos.

## Test plan

Build example apps
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.

5 participants