Urgent.News

What's breaking now, across thousands of outlets.

Tech

React `startTransition` Without `useTransition`: The Standalone API Teams Keep Overlooking in Concurrent Mode

React startTransition Without useTransition : The Standalone API Teams Keep Overlooking in Concurrent Mode This article was written with the assistance of AI, under human supervision and review. Most React concurrent-mode problems stem from teams treating useTransition as the only entry point. The pattern developers overlook is React's standalone startTransition export, a function that schedules…

Teams often overlook the standalone `startTransition` API in React's Concurrent Mode, focusing solely on the `useTransition` hook. This standalone function allows scheduling low-priority updates without needing component scope or hooks, solving a common problem where transitions originate outside the React tree. Unlike `useTransition`, `startTransition` doesn't return an `isPending` flag, which means it doesn't provide a built-in way to indicate when a transition is active.

However, both APIs mark state updates as low priority, enabling React to prioritize urgent work. The standalone `startTransition` function is a plain JavaScript export that can be called from any synchronous context, making it useful for scenarios like updates from third-party state management stores or DOM event handlers that cannot access hooks.

While `useTransition` is preferred when transitions are initiated within React components and require loading indicator feedback, `startTransition` is the go-to when transitions begin in external code and the pending state isn't crucial for the user experience. Both APIs ensure that urgent updates, such as typing in an input or clicking a button, render immediately, while the transition waits in the background.

The choice between the two depends on the code's location and whether the pending status affects the UI.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Sunday 13 September →