title: How to Render React to an ID with Hooks on an HTML Page?
body: <p>Just learning the hook side of things with React. The class components makes sense, but Hooks are missing the render section. </p>
  
  <p>If I'm adding React to a web page, (NOT THE CREATE REACT APP), how do I let my hook know where to run on the HTML page?</p>
  
  <p>I'm trying to place code inside the following:
  <code>&lt;script src="react-hooks.js"&gt;&lt;/script&gt;</code></p>
  
  <p>Here's my hook code:</p>
  
  <pre><code>import React, { useState } from 'react';
  
  function Example() {
      const [count, setCount] = useState(0);
  
      return (
          &lt;div&gt;
              &lt;p&gt;You clicked {count} times&lt;/p&gt;
              &lt;button onClick={() =&gt; setCount(count + 1)}&gt;
                  Click Me
              &lt;/button&gt;
          &lt;/div&gt;
      );
  }
  </code></pre>
  
  <p>However, there's no place in a hook to say this anywhere.
  I've tried this:</p>
  
  <pre><code>const rootElement = document.getElementById("hook-section");
  ReactDOM.render(&lt;Example /&gt;, rootElement);
  </code></pre>
  
  <p>but I get the following error:</p>
  
  <blockquote>
    <p>quote Uncaught SyntaxError: Cannot use import statement outside a module >quote</p>
  </blockquote>
  
  <p>If I update the script call to include <code>type="module"</code>n I get the following:</p>
  
  <blockquote>
    <p>quoteAccess to script at 'file:///C:/Users...react-hooks.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
    index.html:44</p>
    
    <p>quoteGET file:///C:/Users/.../react-hooks.js net::ERR_FAILED</p>
  </blockquote>
  
  <p>Classes still work just fine, but not hooks.
  I am adding js files in a /src file, which when I run babel, it creates a another js version on the root.</p>
  
  <p>I went off the React docs for this.
  <a href="https://reactjs.org/docs/add-react-to-a-website.html" rel="nofollow noreferrer">https://reactjs.org/docs/add-react-to-a-website.html</a> </p>
  
  <p>Step 1: <code>Run npm init -y (if it fails, here’s a fix)</code></p>
  
  <p>Step 2: <code>Run npm install babel-cli@6 babel-preset-react-app@3</code></p>
  
  <p><code>npx babel --watch src --out-dir . --presets react-app/prod</code></p>