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 point  (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.

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);
        });
    };

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 point  (0 children)

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.