Skip to content

[React 19] Proposal: Enhancing useTransition Hook with Timed Start Transition Feature #31830

Closed as not planned
@rajaahsan365

Description

@rajaahsan365

Summary

We propose enhancing React's startTransition function to accept an optional second parameter: a timeout duration (durationInMs). This will ensure the transition runs for at least the specified time, even if the internal logic resolves earlier, enabling smoother UI updates and animations.

#Proposed API
startTransition(callback, durationInMs);

  • callback: Executes state updates or operations as a transition.
  • durationInMs (Optional): Ensures the transition takes a minimum time, adding a delay if the callback resolves sooner.

startTransition(() => { setData(fetchData()); }, 500); // Ensures a minimum 500ms transition
If fetchData resolves in 200ms, the UI remains in a "pending" state for 500ms, ensuring a smoother experience.

#Benefits

  • Enhanced UX: Prevents abrupt UI updates by synchronizing transitions with animations or loaders.
  • Simplified Code: Reduces reliance on setTimeout hacks for timing.
  • Backward Compatible: Fully optional, retaining existing functionality.
  • This addition aligns with React's goal of delivering seamless developer and user experiences. We invite the community to discuss and refine this idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions