Skip to content

useState's setState hangs when called in closed window #16585

Closed
@aaronjensen

Description

@aaronjensen

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions