ammarahm-ed / react-native-actions-sheet

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.
https://rnas.vercel.app
MIT License
1.45k stars 121 forks source link

Crash when trying to close the action sheet. #140

Closed aliraza96 closed 2 years ago

aliraza96 commented 2 years ago

Whenever I try to hide the action sheet, this happens. Simulator Screen Shot - iPhone 13 - 2021-12-21 at 15 57 38

Screenshot 2021-12-21 at 3 57 49 PM
aliraza96 commented 2 years ago

The Detailed Code is given Below ` <View style={{ flexDirection: 'column', margin: 20, marginBottom: 30, }}> <ClickableText onPress={() => { console.log('Add Media'); photoOrVideoActionSheet.current.setModalVisible(); }} textToPut={'Add Media'} textStyle={{ margin: 8, color: colors.blue, alignSelf: 'center', fontSize: 20, fontFamily: 'ProductSans-Medium', }} />

      <ClickableText
        onPress={() => {
          console.log('Delete');
          petOptionsActionSheet.current.hide();
          firestore().collection('allPets').doc(data.petId).delete();
          navigation.goBack();
        }}
        textToPut={'Delete'}
        textStyle={{
          margin: 8,
          marginTop: 16,
          alignSelf: 'center',
          color: colors.blue,
          fontSize: 20,
          fontFamily: 'ProductSans-Medium',
        }}
      />

      <ClickableText
        onPress={() => {
          petOptionsActionSheet.current.setModalVisible();
        }}
        textToPut={'Cancel'}
        textStyle={{
          margin: 8,
          marginTop: 25,
          alignSelf: 'center',
          color: colors.danger,
          fontSize: 20,
          fontFamily: 'ProductSans-Medium',
        }}
      />
    </View>

    <ActionSheet ref={photoOrVideoActionSheet} bounceOnOpen={true}>
      <View
        style={{
          flexDirection: 'column',
          margin: 20,
          marginBottom: 30,
        }}>
        <ClickableText
          onPress={() => {
            console.log('PhotoSelected');
            photoOrVideoSelected = 'photo';
            cameraOrGalleryActionSheet.current.setModalVisible();
          }}
          textToPut={'Photo'}
          textStyle={{
            margin: 8,
            color: colors.blue,
            alignSelf: 'center',
            fontSize: 20,
            fontFamily: 'ProductSans-Medium',
          }}
        />

        <ClickableText
          onPress={() => {
            console.log('VideoSelected');
            photoOrVideoSelected = 'video';
            cameraOrGalleryActionSheet.current.setModalVisible();
          }}
          textToPut={'Video'}
          textStyle={{
            margin: 8,
            marginTop: 16,
            alignSelf: 'center',
            color: colors.blue,
            fontSize: 20,
            fontFamily: 'ProductSans-Medium',
          }}
        />

        <ClickableText
          onPress={() => {
            photoOrVideoActionSheet.current.setModalVisible();
          }}
          textToPut={'Cancel'}
          textStyle={{
            margin: 8,
            marginTop: 25,
            alignSelf: 'center',
            color: colors.danger,
            fontSize: 20,
            fontFamily: 'ProductSans-Medium',
          }}
        />
      </View>

      <ActionSheet ref={cameraOrGalleryActionSheet} bounceOnOpen={true}>
        <View
          style={{
            flexDirection: 'column',
            margin: 20,
            marginBottom: 30,
          }}>
          <ClickableText
            onPress={() => {
              console.log('Camera');

              pickImageOrVideo(
                'camera',
                photoOrVideoSelected,
                returnUri => {
                  console.log('URI:: ' + returnUri);
                  if (photoOrVideoSelected === 'photo') {
                    uploadPhoto(returnUri);
                  } else if (photoOrVideoSelected === 'video') {
                    uploadVideo(returnUri);
                  }
                  petOptionsActionSheet.current?.hide();
                },
              );
              //var uri = cameraOrGallery('camera');
              // try {
              //   petOptionsActionSheet.current.setModalVisible();
              //   // cameraOrGalleryActionSheet.current.setModalVisible();
              //   // photoOrVideoActionSheet.current.setModalVisible();
              // } catch (error) {}
            }}
            textToPut={'Camera'}
            textStyle={{
              margin: 8,
              color: colors.blue,
              alignSelf: 'center',
              fontSize: 20,
              fontFamily: 'ProductSans-Medium',
            }}
          />

          <ClickableText
            onPress={() => {
              console.log('Gallery');
              pickImageOrVideo(
                'gallery',
                photoOrVideoSelected,
                returnUri => {
                  console.log('URI:: ' + returnUri);
                  if (photoOrVideoSelected === 'photo') {
                    uploadPhoto(returnUri);
                  } else if (photoOrVideoSelected === 'video') {
                    uploadVideo(returnUri);
                  }
                  petOptionsActionSheet.current.hide();
                },
              );
            }}
            textToPut={'Gallery'}
            textStyle={{
              margin: 8,
              marginTop: 16,
              alignSelf: 'center',
              color: colors.blue,
              fontSize: 20,
              fontFamily: 'ProductSans-Medium',
            }}
          />

          <ClickableText
            onPress={() => {
              cameraOrGalleryActionSheet.current.setModalVisible();
            }}
            textToPut={'Cancel'}
            textStyle={{
              margin: 8,
              marginTop: 25,
              alignSelf: 'center',
              color: colors.danger,
              fontSize: 20,
              fontFamily: 'ProductSans-Medium',
            }}
          />
        </View>
      </ActionSheet>
    </ActionSheet>
  </ActionSheet>`