Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BottomSheetModalProvider crashing in some circumstances when dismissing a modal #240

Closed
alessiocancian opened this issue Jan 27, 2021 · 3 comments · Fixed by #205 or #244
Closed
Assignees
Labels
bug Something isn't working modal Related to BottomSheetModal v2 Written in Reanimated v1

Comments

@alessiocancian
Copy link

Bug

null is not an object (evaluating 'sheetsQueueRef.current[sheetsQueueRef.current.length - 1].ref.current.restore') when calling bottomSheetModalRef.dismiss().
It happens when the modal is somehow unmounted before the animation ends (in my case because the page is unmounted from the stack of react-navigation), so

Environment info

Library Version
@gorhom/bottom-sheet 2.0.5
react-native 0.63.4
react-native-reanimated 1.13.2
react-native-gesture-handler 1.9.0

Steps To Reproduce

To reproduce the bug you need to unmount the page containing the modal before the animation ends, so that ModalProvider will use a null ref.
I tried to add a setTimeout of 1 second (so the animation ends) before unmounting the page (before calling navigation.goBack()) and everything works fine, so I think that the modal gets removed from sheetsQueue only when animation ends.

I tested with ref.dismiss() and dismiss and dismissAll from useSheetModal() and it always crashes in the same way:

  1. open the modal
  2. dismiss the modal and unmount the page containing it (navigation.goBack) before animation ends
  3. open another modal
  4. when trying to dismiss it (even with drag down) I get the error because bottomSheetModalProvider tries to restore the modal which was unmounted in step 2

Reproducible sample code

I can't provide it right now but I will add it later if you really need it

@alessiocancian alessiocancian added the bug Something isn't working label Jan 27, 2021
@gorhom gorhom linked a pull request Jan 27, 2021 that will close this issue
@gorhom
Copy link
Owner

gorhom commented Jan 27, 2021

this should be resolved with #205

@gorhom gorhom closed this as completed Jan 27, 2021
@alessiocancian
Copy link
Author

Thanks for the quick response, I tested the pr but it crashes on .minimize() when opening the modal at step 3 now.

@gorhom gorhom self-assigned this Jan 28, 2021
@gorhom gorhom reopened this Jan 28, 2021
@gorhom gorhom added modal Related to BottomSheetModal v2 Written in Reanimated v1 labels Jan 28, 2021
@gorhom gorhom reopened this Jan 28, 2021
@gorhom
Copy link
Owner

gorhom commented Jan 29, 2021

this should be fixed with v2.0.7 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working modal Related to BottomSheetModal v2 Written in Reanimated v1
Projects
None yet
2 participants