Description
Scenario
I am trying to use React to dynamically replace a tbody
tag with my app's content. In addition, I need to use a componentDidMount
callback to handle some custom event binding.
Problem
As soon as the componentDidMount
callback is added to React.createClass
, React throws the following errors:
Error while invoking `findComponentRoot` with the following ancestor node: <tbody id="content">…</tbody>
Uncaught Error: Invariant Violation: findComponentRoot(..., .r[3skhu]): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g. by the browser).
Conclusion
The content still renders, but the error is a bit unnerving. Simply removing the callback prevents the errors from being thrown.
I'm brand new to this, so its possible that I'm trying to make React do something that it is not meant to handle. But either way, I think the mere existence of an empty callback should not be throwing any errors.
FWIW, other scenarios that involve injecting content rather than replacing an existing DOMNode seem to work fine with or without the componentDidMount
callback.