chore: update deprecated Reanimated API use with Worklets - #4407
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change migrates gesture components and hooks from legacy Reanimated scheduling APIs to ChangesWorklets scheduling migration
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
Possibly related PRs
Suggested reviewers: 🚥 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 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.runOnUIusage in v3 hook utilities withWorklets.scheduleOnUI. - Updated JS responder / event handler hooks to use Worklets scheduling and Worklet-based worklet detection.
- Migrated
ReanimatedSwipeableandReanimatedDrawerLayoutfromrunOnJS/runOnUI/_WORKLETtoreact-native-workletshelpers.
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
Workletsis undefined,Worklets?.isWorkletFunction(...)evaluates toundefined, so this condition becomes true andonUpdateis replaced withworkletNOOPeven if the user provided a real worklet. That effectively disablesonUpdatehandling wheneverreact-native-workletsisn't available.
if (!Worklets?.isWorkletFunction(handlers.onUpdate)) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eb564d1 to
f5b45f6
Compare
m-bert
left a comment
There was a problem hiding this comment.
Changes look ok, please merge base branch - for now web doesn't work 😞
## 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
Description
🚀
Test plan
🚀