Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix act not flushing effects/updates if global effect/update queues are non-empty before act call #1851

Merged
merged 2 commits into from
Aug 11, 2019

Conversation

robertknight
Copy link
Member

When scheduling a state update or effect, check whether the
options.{debounceRendering, requestAnimationFrame} hooks changed since
an update/effect queue flush was last scheduled and schedule a flush
using the new hooks if so.

This fixes an issue where a call to act would fail to synchronously flush
state updates and effects if a flush was already scheduled but not yet executed
before act was called. This happened because when a state update or effect was
queued during the act callback, if the global update/effect queues were
non-empty then the temporary hooks installed by act to facilitate
synchronously flushing the queue would not be called.

More generally, this fixes an issue where any changes to the scheduling hooks
do not take effect until any already-scheduled flushes have happened.

Fixes #1794

When scheduling a state update or effect, check whether the
`options.{debounceRendering, requestAnimationFrame}` hooks changed since
an update/effect queue flush was last scheduled and schedule a flush
using the new hooks if so.

This fixes an issue where a call to `act` would fail to synchronously flush
state updates and effects if a flush was already scheduled but not yet executed
before `act` was called. This happened because when a state update or effect was
queued during the `act` callback, if the global update/effect queues were
non-empty then the temporary hooks installed by `act` to facilitate
synchronously flushing the queue would not be called.

More generally, this fixes an issue where any changes to the scheduling hooks
do not take effect until any already-scheduled flushes have happened.

Fixes #1794
@coveralls
Copy link

coveralls commented Aug 10, 2019

Coverage Status

Coverage increased (+0.0006%) to 99.876% when pulling 8f4fb12 on handle-flush-hook-changes into 52ab905 on master.

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super awesome! I can only imagine the time it took to debug this 👍 🎉

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.

State updates outside of act interfere with subsequent state updates during act
3 participants