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: useTransition after use gets stuck in pending state #29670

Merged
merged 2 commits into from
May 31, 2024

Commits on May 31, 2024

  1. Add regression test for stuck pending state

    Introduces a regression test for a bug where the pending state of a
    useTransition hook is not set back to `false` if it comes after a
    `use` that suspended.
    
    Co-authored-by: Andrew Clark <git@andrewclark.io>
    eps1lon and acdlite committed May 31, 2024
    Configuration menu
    Copy the full SHA
    c13ea86 View commit details
    Browse the repository at this point in the history
  2. Fix: Wrong dispatcher when replaying after suspend

    When a component suspends with `use`, we switch to the "re-render"
    dispatcher during the subsequent render attempt, so that we can reuse
    the work from the initial attempt. However, once we run out of hooks
    from the previous attempt, we should switch back to the regular
    "update" dispatcher.
    
    This is conceptually the same fix as the one introduced in facebook#26232. That
    fix only accounted for initial mount, but the useTransition regression
    test added in the previous commit illustrates that we need to handle
    updates, too.
    
    The issue affects more than just useTransition but because most of the
    behavior between the "re-render" and "update" dispatchers is the same
    it's hard to contrive other scenarios in a test, which is probably why
    it took so long for someone to notice.
    acdlite committed May 31, 2024
    Configuration menu
    Copy the full SHA
    09f46e4 View commit details
    Browse the repository at this point in the history