-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Closed
Labels
package: react@ionic/react package@ionic/react packagetype: buga confirmed bug reporta confirmed bug report
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
- v4.x
- v5.x
- v6.x
- Nightly
Current Behavior
Conditionally rendering an IonModal, breaks when dismissing when using ionic v6.
Observed behavior: white/blank screen.
Error in console:
react-dom.development.js:10301 Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Expected Behavior
In an ideal scenario - the ionic modal could be conditionally rendered (without using the isOpen prop) this is a common pattern in react applications.
Steps to Reproduce
- Conditionally render an IonModal
...
const [showIonModal, setShowIonModal] = useState(false);
...
return (
<div>
<IonButton onClick={() => setShowIonModal(true)}>
Show Modal
</IonButton>
{showIonModal && (
<IonModal isOpen={true} onDidDismiss={() => setShowIonModal(false)}>
<IonHeader>
<IonToolbar>
<IonTitle>Content</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent fullscreen>
Ionic Modal Content here!
<IonButton color="danger" onClick={() => setShowIonModal(false)}>
Hide Modal (will break)
</IonButton>
</IonContent>
</IonModal>
)}
</div>
)
...- Dismiss the modal (so that IonModal is pulled from the dom)
- Observe the error.
Code Reproduction URL
https://github.com/corysmc/react-overlay-bug
Ionic Info
Ionic:
Ionic CLI : 6.15.0
Ionic Framework : @ionic/react 6.1.13
Utility:
cordova-res : not installed
native-run : 1.6.0
System:
NodeJS : v14.16.0
npm : 6.14.11
OS : macOS Big Sur
Additional Information
Related:
#24887
Metadata
Metadata
Assignees
Labels
package: react@ionic/react package@ionic/react packagetype: buga confirmed bug reporta confirmed bug report