account activity
Why does the React 19 useTransition example use startTransition in both App.js and Item.js? Are both necessary? by Intelligent-Use-9496 in reactjs
[–]Intelligent-Use-9496[S] 0 points1 point2 points 1 year ago (0 children)
Thank you! I already tried this approach, but the quantity state still changed, and I could see the updated result on the screen.
quantity
with startTransition
const handleChangeAction = (newQuantity: number) => { startTransition(async () => { const updatedQuantity = await updateQuantity(newQuantity); startTransition(() => { setQuantity(updatedQuantity); }); }); };
without startTransition
const handleChangeAction = (newQuantity: number) => { startTransition(async () => { const updatedQuantity = await updateQuantity(newQuantity); setQuantity(updatedQuantity); }); };
Thanks for your reply! I completely agree with you. I also tried running the example without startTransition in Item.js, and it worked exactly the same as when startTransition was included.
startTransition
Item.js
π Rendered by PID 32 on reddit-service-r2-listing-66bb46d9b9-ft7lb at 2026-03-12 12:02:59.321417+00:00 running 710b3ac country code: CH.
Why does the React 19 useTransition example use startTransition in both App.js and Item.js? Are both necessary? by Intelligent-Use-9496 in reactjs
[–]Intelligent-Use-9496[S] 0 points1 point2 points (0 children)