⚛️ React 19 upgrades useTransition to handle this natively 👇 . If you are still writing try/finally just to turn off a loading spinner, you are doing it wrong. Every React developer has written this pattern a thousand times: 1. Create a loading state. 2. Set it to true before the fetch. 3. Set it to false after the fetch. 4. Wrap it in try/catch to ensure it doesn't get stuck. It is boilerplate code that clutters your logic. ❌ The Old Way: You manually manage the boolean. If your component unmounts while fetching, you might get "State update on unmounted component" warnings. ✅ The Modern Way: Pass an async function directly to startTransition. React automatically: • Sets isPending to true immediately. • Waits for your async function to finish. • Sets isPending to false automatically. • Interruptible: Keeps the UI responsive during the update. The Shift: We are moving from "Imperative State Management" to "Declarative Transitions." Check the docs: useTransition now accepts async functions! #ReactJS #React19 #WebDevelopment #Frontend #JavaScript #CleanCode #SoftwareEngineering #TechTips #ReactJSTips #Tips #FrontendDeveloper #ReactJSDeveloper #Hooks #SoftwareEngineering
Just use React Query for this use case, it’s better for handling queries in so many cases The main purpose of useTransition is to prioritize state updates. useTransition is used to control update priority in React. It lets you mark certain state updates as non-urgent so that more important updates, like user input, can render immediately. This prevents expensive renders from blocking the UI and keeps the application responsive while heavier updates are processed in the background.
Oh, React... Always brings a smile to my face! Other frameworks do this a lot of time ago! Even with vanilla JS you can do this natively! But well... Wow, React! What a innovation!!
Great job. I really appreciate your effort.
Nothing so meaningful here...
Good post 💪
great post!
Well Said
Georges Metri check this out
great post! But do you use it in a button? is it a boolean variable so you can use the disabled property in a button or a form dynamically?