Skip to content

Add react-native-reanimated v4 support #2374

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lucaswitch
Copy link

First of all, thank you for this library. Basically a "must install" on almost every react-native project.

This pull request is responsible for adding support to react-native-reanimated v4.

Motivation

React Native Reanimated v4 introduces some breaking changes, but we want to maintain compatibility by continuing to support it within the existing v5 branch.

To achieve this, we added a custom useWorkletCallback hook that performs a runtime check: if the original useWorkletCallback is available, it uses it; otherwise, it falls back to the new approach described in the official documentation.

I also removed addWhitelistedNativeProps and addWhitelistedUIProps since they are no longer used in v4.
This update still requires testing before production release, so it can be considered a release candidate for now.

@lucaswitch
Copy link
Author

I'm testing it by including on a example app using: "@gorhom/bottom-sheet": "git+https://github.com/lucaswitch/react-native-bottom-sheet.git",

@lucaswitch
Copy link
Author

Its not done yet. I ll work on it tomorrow

@Splanis
Copy link

Splanis commented Jul 25, 2025

Did anyone faced an issue that BottomSheetModals are being dismissed immediately (they are rendered for like 50ms and closing)? :/

: function useWorkletCallback<T extends (...args: any[]) => any>(callback: T, deps: readonly unknown[]): T {
return useCallback((...args: Parameters<T>): ReturnType<T> => {
'worklet';
return callback?.(...args);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the following error: Error: [Worklets] Tried to synchronously call a non-worklet function evaluatePosition on the UI thread.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i'm seeing that error still looks like the current approach is not enough for inner functions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

evaluatePosition is broken:

image

@lucaswitch
Copy link
Author

Did anyone faced an issue that BottomSheetModals are being dismissed immediately (they are rendered for like 50ms and closing)? :/

This is happening after this pull request somehow there some behavior changes between reanimated v3 and reanimated v4. I'm looking forward to see whats happening.

@lucaswitch
Copy link
Author

Did anyone faced an issue that BottomSheetModals are being dismissed immediately (they are rendered for like 50ms and closing)? :/

This is happening after this pull request somehow there some behavior changes between reanimated v3 and reanimated v4. I'm looking forward to see whats happening.

But must be something with the my application and yours cause the example apple is running smooth

@lucaswitch
Copy link
Author

https://github.com/user-attachments/assets/1b55807e-15e7-4825-a715-33041ee842a4
Test with v3
"react-native-reanimated": "~3.17.4"

@lucaswitch
Copy link
Author

lucaswitch commented Jul 25, 2025

https://github.com/user-attachments/assets/1b55807e-15e7-4825-a715-33041ee842a4 Test with v3 "react-native-reanimated": "~3.17.4"

I'll test on v4

@lucaswitch
Copy link
Author

Did anyone faced an issue that BottomSheetModals are being dismissed immediately (they are rendered for like 50ms and closing)? :/

This is happening on v4

@lyonscrawl
Copy link

lyonscrawl commented Jul 25, 2025

image

Getting this using your master branch and reanimated 4, sometimes it opens or not, sometimes i am getting this error

"@gorhom/bottom-sheet": "github:lucaswitch/react-native-bottom-sheet",
"react-native-reanimated": "~4.0.0",

@lucaswitch
Copy link
Author

image Getting this using your master branch and reanimated 4, sometimes it opens or not, sometimes i am getting this error

"@gorhom/bottom-sheet": "github:lucaswitch/react-native-bottom-sheet", "react-native-reanimated": "~4.0.0",

Yep it's not ready yet. I'm trying to fix it. Also the SectionList example is not working yet.

@lucaswitch
Copy link
Author

Screen.Recording.2025-07-25.at.17.36.08.mov

This is the current behavior with reanimated v4.

@matiaswastaken
Copy link

Yep got same issue with reanimated v4, the BottomSheetModal just closes if the content is smaller than 50% of the height of the device.

@gorhom
Copy link
Owner

gorhom commented Aug 3, 2025

@lucaswitch thanks for submitting this PR, im working now in merging it with #2223 & #2356

@ericpoulinnz
Copy link

Yep got same issue with reanimated v4, the BottomSheetModal just closes if the content is smaller than 50% of the height of the device.

Yeah I get this with reanimated v4 + bottom sheet 5.1.8

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.

7 participants