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.

Invariant Violation: ..... This probably means the DOM was unexpectedly mutated (e.g. by the browser).

See original GitHub issue

I’m getting a whole bunch of errors, starting with: Danger: Discarding unexpected node: ... … finishing with Uncaught Error: Invariant Violation: findComponentRoot(..., .r[129yk].[3].[0].[1].[0].[2].[1]): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g. by the browser).

By changing React.DOM.p (widgets/settings_login.js line 34): https://github.com/agavelab/lostd-app/blob/reactjs-bug/src/scripts/widgets/settings_login.js#L34

to React.DOM.div this problem goes completely away. The problem is cross-browser.

Steps to reproduce

Checkout: https://github.com/agavelab/lostd-app/tree/reactjs-bug cd lostd-app/src python -m SimpleHTTPServer (Maybe you don’t even need this, and it’ll work directly opening index.html with a browser) http://127.0.0.1:8000 And you should see the error in your console

Change React.DOM.p to React.DOM.div and everything is perfect

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

9reactions
zpaocommented, Jan 30, 2014

So the problem here is that when you do <p class="parent"><p class="child"></p></p> browsers are like “aw helllllll no” and they change the DOM to <p class="parent"></p><p class="child"></p> This mutation happens after React has done it’s thing.

This is completely true if you were doing this in straight HTML too, so it’s not a new problem. It’s just that you don’t try to move elements in HTML. You can see this with some simple styles. On top of that, there are several ways in which this can happen. Another example is nested <a> tags.

Here’s an example of the problem in HTML+CSS: http://jsfiddle.net/zpao/fgth2/ (and in fact it looks like the DOM gets super crazy and adds an entirely new <p>. 💩

And since React isn’t doing anything wrong, I’m going to close this out. Use the <div> to wrap <p> and you’ll be fine. Thanks for the detailed report though! I

5reactions
gabrielfloritcommented, Oct 22, 2014

This also happens when I conditionally return a null component, e.g.:

render: function() {

    var component = ifSomething ? (<Component />) : null;

    return component;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught Error: Invariant Violation: findComponentRoot ...
$109): >Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the >browser), usually due to forgetting a when...
Read more >
ReactJs “Invariant violation…” Classic react issue – iTecNote
"Uncaught Error: Invariant Violation: processUpdates(): Unable to find child 2 of element. This probably means the DOM was unexpectedly mutated (e.g., ...
Read more >
Component render() · react-indepth - DevelopmentArc
Uncaught Invariant Violation: findComponentRoot(..., .0): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), ...
Read more >
Uncaught Error: Invariant Violation: findComponentRoot ...
[Solved]-Uncaught Error: Invariant Violation: findComponentRoot(..., ...$110): Unable to find element. This probably means the DOM was unexpectedly mutated- ...
Read more >
Removing item from the DOM causes Invariant Violation on re ...
0.$1.0.1.$4): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a < ......
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