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.

bug: Conditionally rendering ionModal in react - Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

See original GitHub issue

Prerequisites

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

  1. 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>
)
...
  1. Dismiss the modal (so that IonModal is pulled from the dom)
  2. 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: https://github.com/ionic-team/ionic-framework/issues/24887

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:50 (27 by maintainers)

github_iconTop GitHub Comments

2reactions
corysmccommented, Aug 16, 2022

Once I try to use @ionic/react@6.2.3-dev.11660337759.18ea0f7e navigation is broken. Downgrading to 6.2.2 router works fine - but the issue outlined above is still present.

Tapping on a navigation link, changes the URL, then refreshes the app back to the root url

The same thing happened when I downloaded the react conference app - and upgraded to this version of ionic/react.

2reactions
Foowebcommented, Jul 20, 2022

Hello! Just wondering when an update will be made to correct this. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React DOMException: Failed to execute 'removeChild' on 'Node'
This explains the error Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this...
Read more >
Breaking React - a common pattern to avoid
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
Read more >
Gantt for React - The "Failed to execute 'removeChild' on ...
Gantt for React - The "Failed to execute 'removeChild' on 'Node'" error is thrown when double-clicking on a task after upgrading to v21.1.5....
Read more >
React DOMException: Failed to execute 'removeChild' on 'Node'
Coding example for the question React DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of...
Read more >
failed to execute 'removechild' on 'node': the nod 相關資訊:: 哇哇3C ...
Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is no longer a child of this node. bug: Conditionally...
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