Search code examples
meteorreactjsmeteor-react

Meteor+React Error: Uncaught Invariant Violation: _registerComponent(...): Target container is not a DOM element


I am looking at LevelUpTuts Meteor+React for everybody series. I am having " Uncaught Invariant Violation: _registerComponent(...): Target container is not a DOM element. " error but I don't know where the problem is.

client/Main.html
<head>
<title>myResolutions</title>
<meta charset="utf-8"/>
</head>

<body>
<div id="target-render"></div>
<script src="./App.js"></script
</body>

In my App.jsx

client/App.jsx
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component{
render() {
    return (
        <h1> Hello World </h1>
    )
}
}

if(Meteor.isClient){
Meteor.startup(function(){
    ReactDOM.render(<App />,document.getElementById("render-target"));
});
}

Solution

  • It looks like in the html you have the id as "target-render", and in the javascript you have the id as "render-target". They need to match.