gorhom / react-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options 🚀
https://ui.gorhom.dev/components/bottom-sheet
MIT License
6.59k stars 734 forks source link

[v4] | [v2] Expo 51 (new architecture) #1849

Open ryskin opened 2 months ago

ryskin commented 2 months ago

Bug

I encountered an error when trying to use @gorhom/bottom-sheet with bridgeless mode in Expo 51.

Environment info

Library Version
@gorhom/bottom-sheet ^4.6.3
react-native 0.74.1
react-native-reanimated ~3.10.1
react-native-gesture-handler ~2.16.1

Steps To Reproduce

  1. Enable bridgeless mode in Expo 51.
  2. Use BottomSheetScrollView in a component.
  3. Run the app.

Describe what you expected to happen:

  1. The BottomSheetScrollView should render without errors.

Reproducible sample code

import BottomSheet, { BottomSheetScrollView, BottomSheetHandle } from '@gorhom/bottom-sheet'
        <BottomSheet
            style={bottomSheetStyle}
            ref={sheetRef}
            snapPoints={snapPointsConfig}
            index={1}
            enableDynamicSizing
            enablePanDownToClose={enablePanDownToClose}
            backdropComponent={setBackdropComponent && CustomBackdrop}
            animateOnMount={true}
            enableOverDrag={false}
            handleIndicatorStyle={{ backgroundColor: color.border }}
            handleStyle={handleStyle}
            backgroundStyle={{ backgroundColor: color.color_background_white }}
            handleComponent={BottomSheetHandle}
            onClose={onClose}
        >
            <BottomSheetScrollView bounces={false}>
                <View>{children}</View>
            </BottomSheetScrollView>
        </BottomSheet>
 (NOBRIDGE) ERROR  Error: Unexpected nativeTag: function; nativeTag=[object Object]

            createBottomSheetScrollableComponent's ScrollableComponent needs to return
            a reference that contains a nativeTag to a Native HostComponent.

            ref=function fun(a0) { [bytecode] }

This error is located at:
    in BottomSheetScrollView (created by BottomSheetScrollView)
    in RCTView (created by View)
    in View (created by AnimatedComponent(View))
    in AnimatedComponent(View)
    in Unknown (created by PanGestureHandler)
    in PanGestureHandler (created by BottomSheetDraggableViewComponent)
    in BottomSheetDraggableViewComponent (created by BottomSheet)
    in RCTView (created by View)
    in View (created by AnimatedComponent(View))
    in AnimatedComponent(View)
    in Unknown (created by BottomSheet)
    in RCTView (created by View)
    in View (created by AnimatedComponent(View))
    in AnimatedComponent(View)
    in Unknown (created by BottomSheet)
    in RCTView (created by View)
    in View (created by BottomSheetContainerComponent)
    in BottomSheetContainerComponent (created by BottomSheet)
    in BottomSheetGestureHandlersProvider (created by BottomSheet)
    in BottomSheet (created by BottomSheet)
    in SlidingUpPanel (created by MapSlideups)
    in MapSlideups (created by MapPage)
    in RCTView (created by View)
    in View (created by MapPage)
    in MapPage (created by SceneView)
    in StaticContainer
    in EnsureSingleNavigator (created by SceneView)
    in SceneView (created by CardContainer)
    in RCTView (created by View)
    in View (created by CardContainer)
    in RCTView (created by View)
    in View (created by CardContainer)
    in RCTView (created by View)
    in View
    in CardSheet (created by Card)
    in RCTView (created by View)
    in View (created by Animated(View))
    in Animated(View) (created by PanGestureHandler)
    in PanGestureHandler (created by PanGestureHandler)
    in PanGestureHandler (created by Card)
    in RCTView (created by View)
    in View (created by Animated(View))
    in Animated(View) (created by Card)
    in RCTView (created by View)
    in View (created by Card)
    in Card (created by CardContainer)
    in CardContainer (created by CardStack)
    in RNSScreen (created by Animated(Anonymous))
    in Animated(Anonymous) (created by InnerScreen)
    in Suspender (created by Freeze)
    in Suspense (created by Freeze)
    in Freeze (created by DelayedFreeze)
    in DelayedFreeze (created by InnerScreen)
    in InnerScreen (created by Screen)
    in Screen (created by MaybeScreen)
    in MaybeScreen (created by CardStack)
    in RNSScreenContainer (created by ScreenContainer)
    in ScreenContainer (created by MaybeScreenContainer)
    in MaybeScreenContainer (created by CardStack)
    in RCTView (created by View)
    in View (created by Background)
    in Background (created by CardStack)
    in CardStack (created by HeaderShownContext)
    in RNCSafeAreaProvider (created by SafeAreaProvider)
    in SafeAreaProvider (created by SafeAreaProviderCompat)
    in SafeAreaProviderCompat (created by StackView)
    in RCTView (created by View)
    in View (created by GestureHandlerRootView)
    in GestureHandlerRootView (created by StackView)
    in StackView (created by StackNavigator)
    in PreventRemoveProvider (created by NavigationContent)
    in NavigationContent
    in Unknown (created by StackNavigator)
    in StackNavigator (created by Routing)
    in EnsureSingleNavigator
    in BaseNavigationContainer
    in ThemeProvider
    in NavigationContainerInner (created by Routing)
    in Routing (created by App)
    in App (created by App)
    in App (created by withDevTools(App))
    in withDevTools(App)
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in main(RootComponent)
karam1ashqar commented 2 months ago

i had a similar error but it was on web platform, was this on web too or ios or android

zibs commented 2 months ago

I'm on iOS and Android and I ran into this too when running bridgeless. I actually tried just commenting out the code where that error is thrown https://github.com/gorhom/react-native-bottom-sheet/blob/4b2a73991d4356ab13904262206abd3e6c8e2869/src/utilities/getRefNativeTag.ts#L30-L40 and it seemed to work. Not sure if that's actually viable though.

desonyuan commented 2 months ago

+1

markrickert commented 2 months ago

I'm getting this same error when I enable the new architecture using Expo SDK v50. Turning off the new arch makes it work again.

oddanderson commented 2 months ago

i had a similar error but it was on web platform, was this on web too or ios or android

@karam1ashqar were you able to resolve for web? running into this too

karam1ashqar commented 2 months ago

i had a similar error but it was on web platform, was this on web too or ios or android

@karam1ashqar were you able to resolve for web? running into this too

no, you need to not use BottomSheetFlatList and BottomSheetScrollView on web

Lewitje commented 2 months ago

Getting this issue on Expo 51

brentvatne commented 2 months ago

can someone please share a minimal reproducible example that we can clone and run?

zibs commented 2 months ago

Here ya go: https://github.com/zibs/bottom-sheetflat-list-mcve -- I think you'll need to clone and npx expo run:ios

It has new arch/bridgeless enabled and throws the error in the logs/renders nothing in this case

markrickert commented 2 months ago

@zibs My investigation lead me down the same path as you (to patch-package out the throw). It appears that this bug was introduced in #1100 (released in v4.4.5)

Discord maintains their own fork of this repo and uses the new arch and has reverted #1100 in their fork.

Looking at other related issues i'm finding that for new architecture and web support, react-native-reanimated kept the findNodeHandle but not on web since it's not supported. Commenting out this throw also appears to make expo-web work as well. I'll keep using my patched version and report if i see any issues, but that Error was there for a reason, probably... maybe.

Screenshot from @zibs's repo:

Screenshot 2024-06-27 at 9 01 45 AM

obasille commented 1 month ago

@AndreiCalazans would you be ok to have a look at this issue? It seems that the getRefNativeTag() is not working with Expo 51 / React Native 74

AndreiCalazans commented 1 month ago

Hey @obasille I've proposed removing the getRefNativeTag in favor of findNodeHandle here https://github.com/gorhom/react-native-bottom-sheet/pull/1823 but it has not been merged, I suggest patching until that lands if you desire to unblock yourself.

khushal87 commented 1 month ago

Any progress on this issue? This is still relevant for iOS and android for me while using BottomSheetFlatList on new architecture. Few solutions suggest using FlatList from react-native-gesture-handler but I don't think its a proper fix to the problem.

RajeshPandey057 commented 2 weeks ago

Duplicate of 1823, merged and release with v4.6.4. I believe this issue can be closed.