question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android issue for multiple modals

See original GitHub issue

my 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();
      });
    }
  };

test test2

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mmerickelcommented, Sep 20, 2017

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.

  1. The refs gets nulled out temporarily which can cause the backdropRef and/or contentRef to be null 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.

  2. The visible prop may be set to false on the native Modal component while transitioning which causes setState to be called on an unmounted component error inside the animated View.

0reactions
mmazzarolocommented, Sep 22, 2017

@ccycecilyip could you give a shot to @mmerickel solution? Thanks!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found