Skip to content

Bug: startTransition doesn't work with useSyncExternalStore #26382

@josepot

Description

@josepot

React version: 18.2.0

Steps To Reproduce

  1. start a transition (using startTransition) on an external store consumed via useSyncExternalStore that throws a Promise when its getValue function is synchronously evaluated (as a means to suspend the component).

  2. The app blows up with an error in the console stating that:

Uncaught Error: A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition.

Link to code example: https://codesandbox.io/s/starttransition-usesyncexternalstore-ixsl9o?file=/src/App.js

Please have a look at the code in the sandbox above ^, I've tried my best to create a very lean example which illustrates the issue.

The current behavior

Wrapping the component with Suspense works like a charm. However, when using startTransition, then it blows up.

The expected behavior

I would expect it not to throw the error 😅. I mean, the error specifically states that the fix is to wrap the updates with startTransition, which is precisely what it's being done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions