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

Async action support for React.startTransition #28097

Merged
merged 1 commit into from
Jan 26, 2024

Commits on Jan 25, 2024

  1. Async action support for React.startTransition

    This adds support for async actions to the "isomorphic" version of
    startTransition (i.e. the one exported by the "react" package).
    Previously, async actions were only supported by the startTransition
    that is returned from the useTransition hook.
    
    The interesting part about the isomorphic startTransition is that it's
    not associated with any particular root. It must work with updates to
    arbitrary roots, or even arbitrary React renderers in the same app. (For
    example, both React DOM and React Three Fiber.)
    
    The idea is that React.startTransition should behave as if every root
    had an implicit useTransition hook, and you composed together all the
    startTransitions provided by those hooks. Multiple updates to the same
    root will be batched together. However, updates to one root will not be
    batched with updates to other roots.
    
    Features like useOptimistic work the same as with the hook version.
    
    There is one difference from from the hook version of startTransition:
    an error triggered inside an async action cannot be captured by an error
    boundary, because it's not associated with any particular part of the
    tree. You should handle errors the same way you would in a regular
    event, e.g. with a global error event handler, or with a
    local `try/catch`.
    acdlite committed Jan 25, 2024
    Configuration menu
    Copy the full SHA
    2a83d9a View commit details
    Browse the repository at this point in the history