Skip to content

Existence of componentDidMount throws "Error while invoking findComponentRoot" #308

Closed
@dlindahl

Description

@dlindahl
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).

JSFiddle here

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions