-
Notifications
You must be signed in to change notification settings - Fork 94
Migrate from react-native-reanimated
to react-native-worklets
with backward compatibility
#731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I verified that those changes work correctly in the current E/App setup (reanimated3). Adhoc builds are here: Expensify/App#71973 I'll continue verifying the setup with reanimated v4 and worklets |
I also confirm that E/App with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me (mostly reviewed the js part) 👌
xcconfig = { | ||
"OTHER_CFLAGS" => "$(inherited) -DREACT_NATIVE_MINOR_VERSION=#{react_native_minor_version}", | ||
"HEADER_SEARCH_PATHS" => [ | ||
"\"$(PODS_ROOT)/#{react_native_reanimated_node_modules_dir_from_pods_root}/apple\"", | ||
"\"$(PODS_ROOT)/#{react_native_reanimated_node_modules_dir_from_pods_root}/Common/cpp\"", | ||
"\"$(PODS_ROOT)/#{react_native_worklets_node_modules_dir_from_pods_root}/apple\"", | ||
"\"$(PODS_ROOT)/#{react_native_worklets_node_modules_dir_from_pods_root}/Common/cpp\"", | ||
].join(' '), | ||
} | ||
if worklets_installed | ||
xcconfig["OTHER_CFLAGS"] << " -DWORKLETS_INSTALLED=1" | ||
end | ||
s.xcconfig = xcconfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it work if we modify s.xcconfig
directly (without xcconfig
variable)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not, I tried that at first but there was an error about modifying s.xcconfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, alternatively we can just have other_cflags
string variable and append to it instead of having xcconfig
variable
@tomekzaw I tested it on Expensify main and on @blazejkustra PR with reanimated bump and confirm it works as expected. I think we're ready for merge! |
There was a problem hiding this comment.
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 migrates the library from using react-native-reanimated
to react-native-worklets
while maintaining backward compatibility. The changes introduce compile-time detection of which worklets library is available and adapt the code accordingly.
- Updates type definitions to use locally-defined worklet types instead of importing from reanimated
- Adds conditional compilation flags and build configurations for both libraries
- Implements backward-compatible type casting and library detection
Reviewed Changes
Copilot reviewed 13 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/parseExpensiMark.ts | Updates imports to use local WorkletFunction type with generic parameters |
src/commonTypes.ts | Adds comprehensive worklet type definitions for both libraries |
src/MarkdownTextInput.tsx | Updates imports and adds type casting for backward compatibility |
package.json | Adds react-native-worklets as optional dependency while updating reanimated version |
example/package.json | Updates dependency versions for both worklet libraries |
example/babel.config.js | Adds conditional plugin selection based on available worklets library |
cpp/RuntimeDecorator.cpp | Implements conditional compilation for different worklet extraction methods |
cpp/MarkdownGlobal.h | Adds type alias for backward compatibility with ShareableWorklet |
cpp/MarkdownGlobal.cpp | Updates function signatures to use SerializableWorklet type |
apple/MarkdownParser.mm | Adds conditional compilation for worklet type declarations |
android/src/main/cpp/CMakeLists.txt | Implements conditional build configuration for worklets libraries |
android/build.gradle | Adds worklets detection and conditional dependency management |
RNLiveMarkdown.podspec | Implements worklets library detection and conditional iOS configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
worklets_installed = system(%Q[ | ||
cd "#{Pod::Config.instance.installation_root}" && | ||
node -e "require.resolve('react-native-worklets/package.json')" > /dev/null 2>&1 | ||
]) |
Copilot
AI
Oct 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The worklets_installed variable is being set twice with different logic. Line 9-12 uses system() to check if worklets can be resolved, but lines 13-14 overwrite this with a different check. This could lead to inconsistent detection results.
worklets_installed = system(%Q[ | |
cd "#{Pod::Config.instance.installation_root}" && | |
node -e "require.resolve('react-native-worklets/package.json')" > /dev/null 2>&1 | |
]) |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a valid comment - I forgot to remove the previous logic of calculating worklets_installed
value but since it has no effect now, I'll remove it in a followup PR (where we'll remove the react-native-reanimated
entirely)
Details
Related Issues
GH_LINK #726
Manual Tests
Linked PRs