useTransition(): startTransition after await #79549
Unanswered
TheAlexGo
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello guys!
I've been using useTransition in my projects for a while now, but only now I noticed the following problem: https://react.dev/reference/react/useTransition#react-doesnt-treat-my-state-update-after-await-as-a-transition. Like, any state update needs to be put in startTransition, even if we are already inside a transition.
Let's look at the example https://react.dev/reference/react/useTransition#examples:
Here in App.tsx is the code:
If you remove startTransition above setQuantity(savedQuantity):
then... nothing will change. Absolutely.
I don't really understand this rule, if everything works correctly without it.
Here's my example:
Do you think I need to use startTransition inside the condition?
Beta Was this translation helpful? Give feedback.
All reactions