Bottom sheet crashes app due to racing conditions with animated values
See original GitHub issueBug
This will be hard to explain, partly because I’m guessing what the issue is. When using bottom sheet modals, the Expo client app crashes when switching between modals, under some conditions, which are unavoidable especially when using an API to fetch data and then presenting a modal.
I believe the issue is that the animated values are not fully set while the modal is opening or closing, and sometimes it returns nil for the values, which is when the app will crash. Something to do with reanimated. Sorry, I’m being vague because I don’t totally know what is going on.
Why do I suspect the animated value? Because while struggling with this issue, I have managed to see, sometimes, an error such as undefined is not an object (evaluating '_useBottomSheetModal.dismiss')
. Googling it traced it back to reanimated and explained it has to do with animated values.
Oh, and as a bonus problem, I added two commented lines in the snack to demonstrate my previous issue which was automatically closed. That bot is very picky I must say 😉
Environment info
Library | Version |
---|---|
“@gorhom/bottom-sheet” | “^2” |
“react-native” | “https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz” |
“react-native-reanimated” | “~1.13.0” |
“react-native-gesture-handler” | “~1.8.0” |
Steps To Reproduce
I shared a snack below, so no need to explain this.
Reproducible sample code
Have a look at this snack I created: https://snack.expo.io/@kickbk/bottom-sheet-crashes-app-due-to-racing-conditions-with-animated-values Wait for the bottom sheet to appear, then drag it down to dismiss. If needed, drag down twice. It will crash the app on your phone and on the online simulator as well, without warning.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top GitHub Comments
@gorhom Kindly help me how resolve this issue?
ERROR TypeError: undefined is not an object (evaluating ‘_$$_REQUIRE(_dependencyMap[2], “@gorhom/bottom-sheet”).BottomSheetModal’)
thank in advance
hello guys i got this issue can someone help me ### TypeError: undefined is not an object (evaluating ‘_$$_REQUIRE(_dependencyMap[5], “@gorhom/bottom-sheet”).BottomSheetModalProvider’)