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.

Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. at Modal.destroy

See original GitHub issue

Issue description

  • components: Modal
  • reactstrap version #5.0.0-beta.3
  • import method es (if umd, are you using the “full” version (only for v5+)?)
  • react version #16.2.0
  • bootstrap version #4.0.0

What is happening?

Error when unmounting Modal route.

Steps to reproduce issue

1. Create the route

        <Switch>
          <Route
            exact
            path={`${this.props.match.path}/nw`}
            render={(props) => (
              <ComponentAsAModal
                one="two"
                {...props}
              />
            )}
          />
        </Switch>

2. The Component

// The component
class ComponentAsAModal extends React.Component {
  constructor() {
    super();
    this.state = {
      visible: true,
    };
  }

  goBack = () => {
    // Transition to another route. Apparently this is the cause
    // of the error. If wrapped in `setTimeout` the error vanishes.
    this.props.dispatch(push('/some-other-route'));
  };

  close = (e) => {
    this.setState({ visible: false });
  };

  render() {
    return (
      <Modal
        toggle={this.close}
        isOpen={this.state.visible}
        onClosed={this.goBack}
      >
      Modal Content
      </Modal>
    );
  }
}

3. Click on the backdrop to trigger the transition in goBack func.

Error message in console

Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. at Modal.destroy
function destroy() {
   // this line fails because of `this._element`. Idealy we should test if 
   // `this._element` exists before executing `document.body.removeChild`
   document.body.removeChild(this._element);
   this._element = null;
   // rest of the code
}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Imprasnacommented, Dec 22, 2020

Uncaught TypeError: Failed to execute ‘removeChild’ on ‘Node’: parameter 1 is not of type ‘Node’.

I am getting this error so, can anyone help me sort it out?

1reaction
virgofxcommented, Mar 20, 2018

Good catch, I’ll fix this in PR #916 - We do check for existing of element in all the other components, just need to add the one liner here. Thanks for reporting!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to execute removeChild on Node - Stack Overflow
This works for any node (just replace markerDiv with a different node), and finds the parent of the node directly in order to...
Read more >
"Failed to execute 'removeChild' on 'Node': parameter 1 is not ...
"Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'." error message. I can't figure out why I am getting...
Read more >
Failed to execute 'removeChild' on 'Node': parameter 1 is not ...
removeChild method removes a child node from the DOM and returns execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'. Which...
Read more >
Handling DOMException - Failed to execute removeChild
rubyonrails #reactwithrails #reactwithror #rorwithreact #railswithreactHello FriendsIn this lecture, we will work on fixing a DOM exception ...
Read more >
VUEJS项目实践七之Failed to execute 'removeChild' on 'Node'
问题描述:Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.问题背景:在我之前的博文VUEJS项目 ...
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