I have the below index.js file:
import ReactDOM from 'react-dom';
import React, { Component } from 'react';
class Aggregator extends Component{
render(){
return(
<div>
<p>Hello world</p>
</div>
);
}
}
ReactDOM.render(
<div>
<Aggregator/>
</div>,
document.getElementById('content')
);
The HTML file that I am trying to link the above JS file to is index.html. The HTML file is given below:
<!DOCTYPE html>
<html>
<head>
<title>JS Bin</title>
</head>
<body>
<div id="content"></div>
<script src ="./index.js" type="text/javascript"></script>
</body>
</html>
I get a "Target container is not a DOM element" error. I am not sure whether the Javascript file is correctly linked in or what could be the other source of error.
Any help greatly appreciated.
Update: The problem seems to be the same as given in Target container is not a DOM element React.js. But the original question identifies the root cause of the problem but does not mention the solution.
create-react-app