Martin Horvath Martin Horvath - 1 month ago 30
React JSX Question Server Side Rendering with client initialization throws warning

I have a implementation... nothing fancy. I understand all the code but cannot see why I get an error in the web-console:

Replacing React-rendered children with a new root component. If you intended to update the children of this node, you should instead have the existing children update their state and render the new components instead of calling ReactDOM.render

Basically, I have a working JSX file and render it in a mvc view with

@Html.React("myClass",{ data = "Martin" })

The component is rendered fine and I tested it with serverSideOnly etc. All good. But with the above configuration, I get the mentioned error. I looks like React is trying to re-render the component instead of just hooking up event handlers as the documentation says.

Any clue what I am doing wrong?


I actually found out why this error popped up. It has to do with the enclosing html where I - clumsy as I am - created the div with the id-tag that was set for the React-creation. I just deleted the outside div and React created that one for me. So kind of a misunderstanding of React on my side.