react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

[Bug]: BottomSheetModal getting presented again on the next screen

Open yolpsoftware opened this issue 9 months ago • 13 comments
trafficstars

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

iOS

What happened?

We have two screens, and a modal on screen 1 has a button that when pressed, dismisses the modal and navigates to screen 2.

However, the modal of screen 1 gets presented again on screen 2, without any ref.current?.present() being called:

Image

It has to do with a useState hook that gets called too in the modal, so it might be related to a re-render operation of screen 1.

Note: the provided Snack does not run for some reason that I don't understand but have already reported. Just paste the whole App.tsx into a local project and run it from there.

Note that the problem disappears if you enable the setTimeout on line 57.

Reproduction steps

  • Take the code from the reproduction example here: https://snack.expo.dev/@yolpsoftware/bottomsheetmodal-getting-presented-again-on-the-next-screen
  • If you cannot run the Snack, paste the code (just one file, App.tsx) into a local project and run it from there

Reproduction sample

https://snack.expo.dev/@yolpsoftware/bottomsheetmodal-getting-presented-again-on-the-next-screen

Relevant log output


yolpsoftware avatar Feb 19 '25 16:02 yolpsoftware