question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[v4] | Example of BottomSheetModal does not work in iOS with Expo SDK 46

See original GitHub issue

Bug

The modal does not open on iOS, it does open sometimes if we add a console.log in handleSheetChanges it opens sometimes the first time but without animation.

In our real app we saw shadow visible at the bottom of the bottom sheet so it seems like it does not go to the right snappoint or something. When do a ui action the modal suddenly shows up.

Environment info

Library Version
@gorhom/bottom-sheet 4.4.0
react-native 0.69.1
react-native-reanimated 2.9.1
react-native-gesture-handler 2.5.0

Steps To Reproduce

Use expo SDK 46

  1. Run on iOS
  2. Press open modal
  3. Modal does not open, only when you press a second time

Describe what you expected to happen:

  1. Press open modal
  2. Modal opens

Reproducible sample code

import "react-native-gesture-handler";

import React, { useCallback, useMemo, useRef } from "react";
import { View, Text, StyleSheet, Button } from "react-native";
import { BottomSheetModal, BottomSheetModalProvider } from "@gorhom/bottom-sheet";
import { GestureHandlerRootView } from "react-native-gesture-handler";

const App = () => {
  // ref
  const bottomSheetModalRef = useRef<BottomSheetModal>(null);

  // variables
  const snapPoints = useMemo(() => ["25%", "50%"], []);

  // callbacks
  const handlePresentModalPress = useCallback(() => {
    bottomSheetModalRef.current?.present();
  }, []);
  const handleSheetChanges = useCallback((index: number) => {
    // console.log("handleSheetChanges", index);
  }, []);

  // renders
  return (
    <View style={styles.container}>
      <Button onPress={handlePresentModalPress} title="Present Modal" color="black" />
      <BottomSheetModal ref={bottomSheetModalRef} index={1} snapPoints={snapPoints} onChange={handleSheetChanges}>
        <View style={styles.contentContainer}>
          <Text>Awesome 🎉</Text>
        </View>
      </BottomSheetModal>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 24,
    justifyContent: "center",
    backgroundColor: "grey",
  },
  contentContainer: {
    flex: 1,
    alignItems: "center",
  },
});

export default () => {
  return (
    <BottomSheetModalProvider>
      <GestureHandlerRootView style={{ flex: 1 }}>
        <App />
      </GestureHandlerRootView>
    </BottomSheetModalProvider>
  );
};

I can not use the versions I want in the snack it works but i cant upgrade deps there https://snack.expo.dev/@richardlindhout/bottom-sheet-v4-reproducible-issue-template

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

4reactions
Bieluucommented, Aug 2, 2022

Problem and solution has already been described here. This issue occurs because of reanimated bug

2reactions
arjendevoscommented, Jul 21, 2022

What is very strange is that if i import enableLogging and call it enableLogging() it works great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo SDK 46. Today we're announcing the release of…
You'll be able to use expo build to build apps that use SDK 46 and earlier, but not apps that use SDK 47...
Read more >
Expo: 'Withnavigation' & 'gorhom/bottom-sheet' is causing the ...
Our app is running fine on the development mode but the app build is getting stuck at the splash screen. To identify the...
Read more >
Leandro Favre (@FavreLeandro) / Twitter
Expo is a game changer on React Native, and EAS is the best. Great thread! Quote Tweet.
Read more >
Newest 'expo' Questions - Page 4 - Stack Overflow
I have an IOS react native app that uses expo-image-picker to get images from the Image Library and Camera. When testing the app...
Read more >
Building Twitter Bottom Sheet with React Native - YouTube
Hey what's up guys, In this video we learn how to create a beautiful bottom sheet modal using React NativeReact Native Course ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found