Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Invariant Violation: findComponentRoot ... #234

Closed
happypoulp opened this issue Jan 23, 2016 · 3 comments
Closed

Uncaught Invariant Violation: findComponentRoot ... #234

happypoulp opened this issue Jan 23, 2016 · 3 comments

Comments

@happypoulp
Copy link

Hi,

I am getting this issue when navigating from one route /:id to another route /:id:

Uncaught Invariant Violation: findComponentRoot(..., .0.$1.0): 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. Try inspecting the child nodes of the element with React ID ``.

I managed to reproduce this issue in a "minimal" repo here: https://github.com/happypoulp/redux-router-issue . What seems to create the issue is the dispatch of a thunk action (one request action that reset store and a bit later a success action that populate the store). Somehow, when navigating from /1 to /2, many render phases are triggered which seems normal but during one of them, stale data are provided to a component. It ends up making React to search for elements that were already removed from the DOM during a previous render phase and then the error is thrown.

It's not very clear to me what's happening but the thing is, that I was only able to reproduce this issue using redux-router (I use version 1.0.0-beta5 and got no issue without redux-router, with just react-router). I also reproduced it with redux-router@1.0.0-beta6.

Is this a bug or am I misunderstanding something?

Thanks for redux-router!

@happypoulp
Copy link
Author

Maybe this issue is actually a manifestation of react issue: facebook/react#2410 .

@Scarysize
Copy link
Contributor

Hm, it seems like it yeah. I don´t have the time to try it out myself though. I will close this up, assuming this is a react issue, will reopen if more people do have this issue. Thanks for reporting and researching, always appreciated!

@davidcrouch
Copy link

I'm commenting because I think there is some justification for re-opening this issue. IMO the error reported in React is a byproduct of a design pattern flaw in Redux apps and not necessarily a bug. In my situation I am using multiple instances of a component and Redux with async flow - very similar to @happypoulp's example. The error occurs when loading the component for the second time. Coincidentally, I also stopped the error by removing the dispatch(REQUEST) line in my code.

My store includes an "isLoading" key and a "results" key. I call "dispatch(REQUEST, isLoading=true)" before calling the asynchronous get data API and then call "dispatch(RESPONSE, isLoading=false, results=[..])" upon receiving the response from the server API.

The error is produced in the component from the properties from the REQUEST call, specifically, when results=[], but only when loading for the 2nd time. The 1st time it works fine. It appears there is a problem when trying to change the nodes in the table body of my app since they no longer exist (unmounted).

Unfortunately, I don't fully understand the internals of React's diffing algorithm so I can't articulate the exact problem but I think I'm close. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants