Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactJS - ReactMount: Root element has been removed from its original container. New container

What this error mean? How to fix that?

ReactMount: Root element has been removed from its original container. New container

After this I get this:

Uncaught object react.js:15915
invariant react.js:15915
ReactMount.findComponentRoot react.js:10584
ReactMount.findReactNodeByID react.js:10480
getNode react.js:10089
(anonymous function) react.js:7307
(anonymous function) react.js:11403
processQueue react.js:10856
ReactMultiChild.Mixin.updateChildren react.js:10970
ReactDOMComponent.Mixin._updateDOMChildren react.js:7007
(anonymous function) react.js:6860
(anonymous function) react.js:11403
ReactComponent.Mixin._performUpdateIfNecessary react.js:4409
ReactComponent.Mixin.receiveComponent react.js:4380
ReactDOMComponent.Mixin.receiveComponent react.js:6833
(anonymous function) react.js:5963
(anonymous function) react.js:11403
ReactCompositeComponentMixin._performComponentUpdate react.js:5899
ReactCompositeComponentMixin._performUpdateIfNecessary react.js:5842
Mixin.perform react.js:14266
ReactComponent.Mixin.performUpdateIfNecessary react.js:4390
ReactCompositeComponentMixin.performUpdateIfNecessary react.js:5792
enqueueUpdate react.js:12731
ReactCompositeComponentMixin.replaceState react.js:5676
ReactCompositeComponentMixin.setState react.js:5655
(anonymous function) posts.js:273
j jquery-1.11.1.min.js:2
k.fireWith jquery-1.11.1.min.js:2
x jquery-1.11.1.min.js:4
b

When I get those problems I'm trying to update my view with a new list of items. To update my current view I call updatePosts():

var updatePosts = function () {
    var content = document.querySelector('.content');
    content.innerHTML = '';
    $refresh.addClass('fa-spin');
    return React.renderComponent(
        <Posts />,
        content
    );
};

Can be this innerHTML = '' the problem? I'll render my Posts component entire again.

like image 373
Filipe Névola Avatar asked Jul 16 '14 12:07

Filipe Névola


1 Answers

Remove this line

content.innerHTML = '';

React will look at the old virtual dom, and what's returned by <Posts /> (which is the same as Posts()). It'll compare them, and make the updates required to the DOM.

like image 63
Brigand Avatar answered Oct 04 '22 19:10

Brigand