onModalHide
is never called if the Modal
is unmounted while still visible
#770
Labels
onModalHide
is never called if the Modal
is unmounted while still visible
#770
Environment
Platforms
Android, iOS and Web
Versions
Description
When the
Modal
is hidden becauseisVisible
changes fromtrue
tofalse
, theonModalHide
will be called.But when the
Modal
is hidden because it's unmounted (isVisible
is stilltrue
), theonModalHide
is never called. This leads to problems because we often useonModalHide
to perform some clean-up, or show a different UX when the modal is hidden.Reproducible Demo
Here's the repository that contains the minimal reproducible example: https://github.com/tienifr/react-native-modal-bug-reproducible-example.
This is a new React Native project, bootstrapped using @react-native-community/cli.
react-native-modal
was added and some minor code was added to showcase the error (via this commit). The steps to run it are in the README.After running it, we can see:
Modal
with textI am the modal content!
will show (due to this code)Modal
with textI am the modal content!
will disappear (due to this code)onModalHide
, which should log this, is never called.Video showing the logs in
onModalHide
never happenedhttps://github.com/react-native-modal/react-native-modal/assets/113963320/25b87f23-7872-4619-a28a-926106a4f377
The text was updated successfully, but these errors were encountered: