title: React - Uncaught Error: Target container is not a DOM element
body: <p>I'm new to react.</p>
  
  <p>My error is:</p>
  
  <blockquote>
    <p>Uncaught Error: Target container is not a DOM element</p>
  </blockquote>
  
  <p>I've Googled this plenty of times and find people who have this error:</p>
  
  <blockquote>
    <p>Uncaught Error: Invariant Violation: _registerComponent(...): Target container is not a DOM element.</p>
  </blockquote>
  
  <p>Mine doesn't contain:</p>
  
  <blockquote>
    <p>_registerComponent(...):</p>
  </blockquote>
  
  <p>Here are my files:</p>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;React&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;div id="root"&gt;&lt;/div&gt;
      &lt;script src="./bundle.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>index.jsx</strong></p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  
  ReactDOM.render(
      &lt;div&gt;
          &lt;h1&gt;Hello World!&lt;/h1&gt;
      &lt;/div&gt;, 
      document.getElementById('root')
  );
  </code></pre>
  
  <p><strong>webpack.config.js</strong></p>
  
  <pre><code>const path = require('path');
  
  module.exports = {
      context: path.join(__dirname, 'src'),
      entry: './index.jsx',
      output: {
          path: path.join(__dirname, 'public'),
          filename: './bundle.js'
      },
      module: {
          loaders: [
              { test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
              { test: /\.jsx$/, loader: 'babel-loader', exclude: /node_modules/ },
          ],
      },
      resolve: {
          modules: [
              path.join(__dirname, 'node_modules')
          ]
      }
  };
  </code></pre>
  
  <p>The most common issue I found people were having with this error is that they put <code>&lt;script&gt;</code> in the head or before the <code>&lt;div&gt;</code>. Yet I don't do neither of these so I have no idea what the problem is.</p>