Skip to content

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

Open
tjzel wants to merge 3 commits into
@tjzel/drop-in-workletsfrom
@tjzel/worklet-api
Open

chore: update deprecated Reanimated API use with Worklets#4407
tjzel wants to merge 3 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

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: 1b5bf924-2d7f-433f-8ac7-1326bff2e34d

📥 Commits

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

⛔ Files ignored due to path filters (2)
  • .yarn/patches/react-native-worklets-npm-0.9.1-5bc5b900ed.patch is excluded by !**/.yarn/**
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • apps/basic-example/package.json
  • apps/common-app/package.json
  • apps/expo-example/package.json
  • apps/macos-example/package.json
  • packages/react-native-gesture-handler/package.json

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Updated gesture, drawer, swipe, and responder interactions to use modern worklet scheduling APIs.
    • Improved compatibility with current React Native worklet and animation 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, test mocks, 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 scheduleOnRN, scheduleOnUI, isWorkletRuntime, and direct shared-value checks.
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.
Align test mocks
packages/react-native-gesture-handler/src/__tests__/runOnJSReanimatedHandlers.test.tsx
The mocked Reanimated object removes unused legacy members.

Sequence Diagram(s)

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

Possibly related PRs

Suggested reviewers: m-bert

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: 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.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/basic-example/package.json

Parsing error: ESLint was configured to run on <tsconfigRootDir>/apps/basic-example/package.json using parserOptions.project: /tsconfig.json
The extension for the file (.json) is non-standard. You should add parserOptions.extraFileExtensions to your config.

apps/common-app/package.json

Parsing error: ESLint was configured to run on <tsconfigRootDir>/apps/common-app/package.json using parserOptions.project: /tsconfig.json
The extension for the file (.json) is non-standard. You should add parserOptions.extraFileExtensions to your config.


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.

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