Android issue for multiple modals
See original GitHub issuemy current version: v2.4.0
Attached the screenshots, on testing with the example.
If we close the modal by pressing android back button instead of the close button, warning message will be shown when we open another modal.
After quick checking on source code, I made the following workaround, but I am not sure if it will break other behaviour.
_close = async () => {
if (this.state.isVisible) {
this.backdropRef.transitionTo({ opacity: 0 }, this.props.backdropTransitionOutTiming);
this.contentRef[this.props.animationOut](this.props.animationOutTiming).then(() => {
this.setState({ isVisible: false });
this.props.onModalHide();
});
}
};
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
React Native multiple modals on one page question
EDIT - I am NOT trying to open multiple modals at once. Only one will be open at a time. But I want...
Read more >react-native-modal - npm
See the question above. Showing multiple modals (or even alerts/dialogs) at the same time is not doable because of a react-native bug.
Read more >How to handle multiple modals in react-bootstrap? - Reddit
Using the same show state for both modals might be the issue. Try creating a showEdit and showCreate.
Read more >ion-modal: Ionic Mobile App Custom Modal API Component
ion-modal is a dialog that appears on top of mobile app content, and must be dismissed before interaction resumes. Learn more about custom...
Read more >Dialogs - Android Developers
A dialog does not fill the screen and is normally used for modal ... Chain together various setter methods to set the dialog...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I do not think this is directly related to the back button. Rather if
isVisible
gets toggled quickly while transitioning occurs some pretty bad things happen.The refs gets nulled out temporarily which can cause the
backdropRef
and/orcontentRef
to benull
which causes the promise rejection seen above. Semi-related is this issue https://github.com/facebook/react/issues/4533 but the real issue is just that_close
is called while already closing and/or opening.The
visible
prop may be set tofalse
on the nativeModal
component while transitioning which causessetState
to be called on an unmounted component error inside the animatedView
.@ccycecilyip could you give a shot to @mmerickel solution? Thanks!