chore: update deprecated Reanimated API use with Worklets - #4407
Conversation
|
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 ignored due to path filters (2)
📒 Files selected for processing (5)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change migrates gesture components and hooks from legacy Reanimated scheduling APIs to ChangesWorklets scheduling migration
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
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
apps/basic-example/package.jsonParsing error: ESLint was configured to run on apps/common-app/package.jsonParsing error: ESLint was configured to run on 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
Description
🚀
Test plan
🚀