th3rdwave / react-navigation-bottom-sheet

MIT License
423 stars 18 forks source link

Closing all open modals. #11

Open izakfilmalter opened 1 year ago

izakfilmalter commented 1 year ago

It seems really hard to close all open modals. I have two modals that are open using stackBehavior: 'replace'. The second modal contains a form that navigates to a different screen on submit. When I submit, it navigates to the new screen, and then opens the old modal again.

I have tried calling dismissAll from useBottomSheetModal. I have tried doing calling Navigation.goBack() and then Navigation.navigate.

izakfilmalter commented 1 year ago

Did some more testing. Tried doing navigation.replace, didn't work. Seems like we need some way to override the following:

  const onDismiss = React.useCallback(() => {
    // BottomSheetModal will call onDismiss on unmount, be we do not want that since
    // we already popped the screen.
    if (isMounted.current) {
      navigation.goBack();
    }
  }, [navigation]);

Maybe an exit all modals function.