react-native: NSInvalidArgumentException __76-[RCTModalHostViewManager presentModalHostView:withViewController:animated:]_block_invoke.38 Application tried to present modally a view controller that is already being presented by

Description

App is crashed and showing below error. NSInvalidArgumentException __76-[RCTModalHostViewManager presentModalHostView:withViewController:animated:]_block_invoke.38 Application tried to present modally a view controller <RCTModalHostViewController: 0x7fcf53855110> that is already being presented by <UIViewController: 0x7fcf4791

Steps to reproduce

react-native run-ios

React Native Version

0.73.7

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.2.1
  CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Memory: 572.45 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.7.3
    path: /usr/local/bin/node
  Yarn: Not Found
  npm:
    version: 10.5.0
    path: /usr/local/bin/npm
  Watchman:
    version: 2023.03.13.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/gopi/.rvm/gems/ruby-2.7.6/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "23"
      - "24"
      - "25"
      - "26"
      - "27"
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 29.0.2
      - 30.0.3
      - 33.0.1
      - 34.0.0
    System Images:
      - android-29 | Google APIs Intel x86 Atom
      - android-29 | Google Play Intel x86 Atom
      - android-30 | Google APIs Intel x86 Atom
      - android-32 | Google APIs Intel x86 Atom_64
      - android-32 | Google Play Intel x86 Atom_64
      - android-33 | Google APIs Intel x86 Atom_64
      - android-33 | Google Play Intel x86 Atom_64
    Android NDK: Not Found
IDEs:
  Android Studio: 2021.2 AI-212.5712.43.2112.8609683
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 18.0.2.1
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/gopi/.rvm/rubies/ruby-2.7.6/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.7
    wanted: 0.73.7
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

NSInvalidArgumentException __76-[RCTModalHostViewManager presentModalHostView:withViewController:animated:]_block_invoke.38 Application tried to present modally a view controller <RCTModalHostViewController: 0x7fcf53855110> that is already being presented by <UIViewController: 0x7fcf4791

Reproducer

https://github.com/gopikrishnacse55/UIExample.git

Screenshots and Videos

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 17 (1 by maintainers)

Most upvoted comments

Sorry, my team forgot to provide the issue in github repo.

Loginpage.js import React,{Component} from “react”; import {View,Text,} from ‘react-native’; import { CommonActions } from ‘@react-navigation/native’; class Loginpage extends Component {

constructor(props) {
    super(props);
    this.state = {
     
    };
  }
handleLogin()
{
    const resetAction =  CommonActions.reset({ index: 0,routes: [ { name: "HomePage" },],})
    this.props.navigation.dispatch(resetAction);
}
render()
{
    return(
    
        <View style={{flex:1,alignItems:'center',justifyContent:'center'}}>
            <Text onPress={()=>this.handleLogin()}>Login</Text>
        </View>
    )
}

}

export default Loginpage;

HomePage.js import React, { Component } from ‘react’; import { View, Text, TouchableOpacity } from ‘react-native’; import { CommonActions } from ‘@react-navigation/native’; import AlertPro from “react-native-alert-pro”; export default class HomePage extends Component { constructor(props) { super(props); this.state = {

};

}

openConfirmationDialog = () => {

this.AlertPro.open();

}

handleLogout() { const resetAction = CommonActions.reset({ index: 0, routes: [ { name:‘Loginpage’ }, ], }) this.props.navigation.dispatch(resetAction); } render() {

return (

  <View style={{ flex: 1,backgroundColor:'red' }}>
   
    <TouchableOpacity onPress={()=>this.openConfirmationDialog()}style={{flex:1,alignItems:'center',justifyContent:'center'}}>
      <Text>Logout</Text>
    </TouchableOpacity>
    <AlertPro
      ref={ref => {
        this.AlertPro = ref;
      }}
      title="Logout"
      message="Do you want to Logout ?"
      textCancel="No"
      textConfirm="Yes"
      onConfirm={() => this.handleLogout()}
      onCancel={() => this.AlertPro.close()}
      customStyles={{

        mask: {
          backgroundColor: "rgba(0, 0, 0, 0.6)"
        },
        container: {
          borderWidth: 1,
          borderColor: "#E6E6E6",
          width: 300,
        },
        buttonCancel: {
          backgroundColor:'#5E4D46'

        },
        buttonConfirm: {
          backgroundColor:'#5E4D46'
        }
      }}
    />
  </View>
);

} }

https://github.com/facebook/react-native/assets/90603484/fc10614c-e2b3-4279-b56b-16a85c20a726

@testloancare - I temporarily fixed this issue.

onConfirm={() => this.AlertPro.close(); setTimeout(() => { this.handleLogout(); }, 1000); }