Skip to content

Conversation

savelichalex
Copy link

This is an actual case from our project.

Let's pretend we have a list with items, that could have popovers. For each item we render popover with prop isVisible set to false. Then we actually show one of them, and by click on it, we unmount the whole list.

Because of the hook in the Popover we will get a lot of simultaneous calls to a PopoverContainer to unregister components, and it could lead to race condition as setState may be asynchronous.

But usage of setState with a callback parameter is guarantee that an actual state will be used at each point.

In our case the race condition is happen consistently with a list that is unmounted completely after interaction with a popover, especially if it was a first popover in a list (remember we render it with items), because all other items, just get a copy of state without the removed item and the popover just stays in the registry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants