title: create new div onClick in React
body: <p>I need to create new empty div onClick every time not once, is it right way to do this in react, I just doubt if it is correct to do this in react</p>
  <pre><code>import &quot;./styles.css&quot;;
  
  export default function App() {
    const parentRef = useRef();
  
    const createNewDiv = () =&gt; {
      parentRef.current.appendChild(document.createElement(&quot;div&quot;));
    };
  
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;div onClick={createNewDiv} ref={parentRef}&gt;
          clickHere
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
  </code></pre>