Uncaught Error: Invariant Violation: findComponentRoot: Unable to find element.
See original GitHub issueI have this modal, in this component:
var Modal = React.createClass({
componentDidMount: function () {
var modal = $('[data-remodal-id=modal]').remodal();
$("button[type=submit]").on('click', function(e){
e.preventDefault();
modal.open();
})
},
_handleVerify: function (e) {
e.preventDefault();
console.log('verifying....');
//console.log(this.refs.vericationCode);
},
render: function () {
return(
<div className="remodal" data-remodal-id="modal">
<button data-remodal-action="close" className="remodal-close"></button>
<h1>Per attivare autenticazione OTP segui le istruzioni</h1>
<p>
Inserisci il tuo secret {this.props.secret} in Google authenticator, e inserisci il codice a 6 cifre prodotto qui
</p>
<br />
<form>
<div className="form-group">
<input type="text" className="form-control" id="vericationCode" placeholder="Enter Verification Code" ref="vericationCode" />
</div>
<button className="remodal-confirm" onClick={this._handleVerify}>Verica</button>
</form>
</div>
);
}
});
But when I click on the button, and trigger this._handleVerify
, it gives me:
Uncaught Error: Invariant Violation: findComponentRoot(..., .0.1.1.1.4.1): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a <tbody> when using tables, nesting tags like <form>, <p>, or <a>, or using non-SVG elements in an <svg> parent.
The component .0.1.1.1.4.1
it is the button. And this not happen if I remove the onClick event trigger on the element. I can’t figure out what is the problem!
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top 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 >Uncaught Error: Invariant Violation: findComponentRoot ...
$110): Unable to find element. This probably means the DOM ... So the problem is you're creating a virtual DOM structure like this:...
Read more >Javascript – Uncaught Error: Invariant Violation: findComponentRoot ...
Javascript – 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 ...
Uncaught Error : Invariant Violation: findComponentRoot(..., .1.1.0.1.0.$1.0.1.$4): Unable to find element. This probably means the DOM was ...
Read more >HipChat Server: Unable to Remove Users from Private Room
... [2407_1@hipchat.example.com] [WebCore] [ERROR] Invariant Violation: findComponentRoot(..., .0.2.0): Unable to find element.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ciaoben The point of using React is that you should not be modifying the DOM, so the ‘correct’ solution is to not use
remodal
. Instead, you should define your UI declaratively such that no DOM manipulations are needed.If you’re trying to popup a modal, I would recommend watching Ryan Florence’s talk (http://conf.reactjs.com/schedule.html#hype) and playing with the portals demo located in
demos/03-portals
of https://github.com/ryanflorence/reactconf-2015-HYPEDo you know what the
$.remodal()
function is doing? Essentially what seems to be happening here is that yourcomponentDidMount
code is modifying the DOM. React jealously wants full control of manipulating the DOM. So a more proper rails way of doing these things would be using state and displaying a modal depending on state: