Skip to content

When calling a useTransition startTransition callback outside of event handlers, isPending is never set to true #17272

Closed
@kentcdodds

Description

@kentcdodds

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

isPending is never set to true when calling startTransition within useEffect, but it does work properly when within a useLayoutEffect.

https://codesandbox.io/s/usetransition-useeffect-issues-p1j9s

Here's the correct behavior (accomplished via useLayoutEffect):

good

Here's the incorrect behavior (via useEffect):

bad

Note the difference is that the opacity never changes to 0.4 (which is determined based on the isPending state).

What is the expected behavior?

I expect them to both behave the same (at least as far as the user can observe).

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

  • react@0.0.0-experimental-f6b8d31a7
  • react-dom@0.0.0-experimental-f6b8d31a7

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions