title: React States to create external link with Window Location url
body: <p>I have a situation where I need to put a state in my <code>window.location.href='http://url.com'</code></p>
  
  <p>At the moment I have the following situation which works</p>
  
  <pre><code>const [url,setUrl] = useState('');
  
  useEffect(() =&gt; {
     getUrl()
       .then(x =&gt; x.json())
       .then(x =&gt; {
          const { result } = x;
          setUrl(result);
        });
    });
  
  &lt;a target="_blank" href={url}&gt;Url/a&gt;
  </code></pre>
  
  <p>Now my need is to change <code>&lt;a target="_blank" href={url}&gt;Url/a&gt;</code> to </p>
  
  <pre><code>&lt;button onClick={(e): void =&gt; { e.preventDefault(); window.location.href={url}}}
  </code></pre>
  
  <p>The problem is I get this error on <strong>window.location</strong></p>
  
  <p><em>Type '{ url: string; }' is not assignable to type 'string'.</em></p>
  
  <p>How do i fix it? Is there a better way to put the sate link on click event?</p>