title: Copy div content on button click in React
body: <p>I want to copy the div content on button click.</p>
  <pre><code>import React from 'react';
  
  const App = () =&gt; {
  
  const copyCode = () =&gt; {
      //TODO
  }
  
  const data = &quot;www.test.com&quot;;
  
  const srcCode = `&lt;script src=${data}&gt;&lt;/script&gt;`;
  
  
  return (
      &lt;&gt;
      &lt;div&gt;
        {srcCode}
      &lt;/div&gt;
      &lt;button onClick={copyCode}&gt;
          Copy
      &lt;/button&gt;
      &lt;/&gt;
  );
  }
  </code></pre>
  <p>export default App;</p>