Skip to content

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

@tigranpetrossian
Copy link

@lucaswitch @gorhom Thanks for doing this.
This is a bit of a blocker for what I'm working on, anything I can help with to get this in?

@lucaswitch
Copy link
Author

Yes! every help wanted, what we are facing now is a behavior change between reanimated v3 and v4 somehow on modals it cannot detect the children elements size correctly.
I'm in a middle of a release in the company i'm working on so i'm not working on it this week.

@tigranpetrossian
Copy link

Thanks @lucaswitch
It looks like updating RNR to v4.0.2 fixes the modal issue, but I had no luck so far in understanding the cause for SectionList/VirtualizedList crashing. Will spend a little more time later today looking into it.

@gorhom gorhom force-pushed the master branch 2 times, most recently from 425b6ec to a123b17 Compare August 17, 2025 21:39
@Chirag7096
Copy link

Chirag7096 commented Sep 11, 2025

I tried the template with EXPO SDK 54, and it's not working

I get a warning
Couldn't find the scrollable node handle id!

And when I try to scroll, the app crashes

My basic code

<BottomSheetModal>
    <BottomSheetScrollView>
        {My code...}
    </BottomSheetScrollView>
</BottomSheetModal>

package.json

    "@gorhom/bottom-sheet": "^5.2.6",
    "react-native-reanimated": "~4.1.0",
    "react-native-worklets": "^0.5.1"

@christophehurpeau
Copy link

@lucaswitch @tigranpetrossian I don't know why exactly but after investigating using AI the issue on SectionList/VirtualizedList crashing seems to be related to useAnimatedRef of useScrollHandler: changing it to useRef make it works but I have no idea what this change would break.
image

Not sure about the AI but this is what it is saying:
image

I hope this helps ?

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.