DOM-element error


I’m practicing React and trying to create a component, a navbar. So far so good, but when I refresh browser I get “Error: Target container is not a DOM element.”

at this line: ReactDOM.render(<Nav />, document.getElementById('nav'));
My React-code:

import React from 'react';
import ReactDOM from 'react-dom';

class Nav extends React.Component {
  render() {
    const nav_style = {
    return (
        <div style={nav_style}>
            <a href="index.html">Home</a>


ReactDOM.render(<Nav />, document.getElementById('nav'));
My html:
  <nav id="nav"></nav>

	<div id="root"></div>

<script src="/components/nav.js"></script>

Perhaps my file structure is wrong?

Do you have the full project somewhere online?

You have document.getElementById('nav') but your div has id="root"