title: copy to clipboard is not working as expected in reactjs
body: <p>I tried to do the copy to the clipboard feature in react js. But I am unable to do that.
  Here is my code</p>
  <pre><code>import { useEffect, useRef } from &quot;react&quot;;
  
  function App() {
    const inputRef = useRef(&quot;&quot;);
    useEffect(() =&gt; {
      inputRef.current.value = window.location;
      inputRef.current.select();
      document.execCommand(&quot;copy&quot;);
    }, []);
    return (
      &lt;div className=&quot;App&quot;&gt;
        &lt;input type=&quot;text&quot; ref={inputRef} /&gt;
      &lt;/div&gt;
    );
  }
  
  export default App;
  </code></pre>
  <p>codesandbox: <a href="https://codesandbox.io/s/gallant-tesla-6399m?file=/src/App.js:0-352" rel="nofollow noreferrer">https://codesandbox.io/s/gallant-tesla-6399m?file=/src/App.js:0-352</a></p>
  <p>text is getting selected but it is not copying. How to fix this issue?</p>