<!--
  Note: if the issue is about documentation or the website, please file it at:
  https://github.com/reactjs/reactjs.org/issues/new
-->

**Do you want to request a *feature* or report a *bug*?**

Bug

**What is the current behavior?**

If useState's setState is called in a closed window, it hangs the browser (at least Chrome). I agree that this seems like a weird issue, but we do this all of the time in our plugin we've built for an application that has iframe based UI.

This reproduces it. Just click "Do it". Note that your codesandbox service worker will spin up to 100% cpu and I can't figure out a way to stop it other than to kill that task in the Chrome task manager

https://codesandbox.io/s/react-setstate-on-hidden-window-hangs-repro-cixqn

**What is the expected behavior?**

No hang, it should just ignore the setState call, ideally.

**Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?**

16.9. I'm not sure, but hooks are fairly new. This reproduces in Chrome 76, but not Firefox as far as I can tell.

'canceled in `componentWillUnmount`), or you can change the test itself ' +
          'to be asynchronous.',
      );
      const evt = document.createEvent('Event');
      
      
      
      
      
      
      let didError = true;
      
      
      
      const windowEvent = window.event;
      
      
      const windowEventDescriptor = Object.getOwnPropertyDescriptor(
        window,
        'event',
      );
      
      
      
      const funcArgs = Array.prototype.slice.call(arguments, 3);
      function callCallback() {