0

I am facing the following error when I am trying to Import a component in react.

Uncaught TypeError: Cannot read property 'replaceChild' of null at Function.replaceChildWithTree (index_bundle.js:4067) at Object.dangerouslyReplaceNodeWithMarkup (index_bundle.js:21337) at Object.dangerouslyReplaceNodeWithMarkup [as replaceNodeWithMarkup] (index_bundle.js:7162) at ReactCompositeComponentWrapper._replaceNodeWithMarkup (index_bundle.js:22799) at ReactCompositeComponentWrapper._updateRenderedComponent (index_bundle.js:22789) at ReactCompositeComponentWrapper._performComponentUpdate (index_bundle.js:22739) at ReactCompositeComponentWrapper.updateComponent (index_bundle.js:22660) at ReactCompositeComponentWrapper.performUpdateIfNecessary (index_bundle.js:22576) at Object.performUpdateIfNecessary (index_bundle.js:4277) at runBatchedUpdates (index_bundle.js:1846) 

My Component is:

import React from 'react' export default class NoticeCard extends React.Component { render() { return ( <section className="centered white"> <div className="container section"> <div className="center"> <p>Invalid Username/Password </p> </div> </div> </section> ) } 

}

The Component is rendered in but the console throws the error.

2
  • is there another error in the console before this one? Commented Jun 26, 2017 at 17:51
  • no. this is the only error. it occurs when I change state of the parent component to render the Noticecard. Commented Jun 26, 2017 at 19:16

1 Answer 1

1

This error is just a symptom, there is a crash somewhere in your code that is being swallowed.

It could be an indication that the DOM has been modified outside of React's control (parent is null, so when replacing a child it tries to call replaceChild on null). Make sure the parent component is not being changed to null or undefined.

check this thread: https://github.com/facebook/react/issues/6998

and especially this comment: https://github.com/facebook/react/issues/6998#issuecomment-263336611

Sign up to request clarification or add additional context in comments.

1 Comment

thanks. I solved the problem after understanding the error.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.