What is wrapping a next server action in startTransition doing?

This was brought up in another question. I came up with the following explination, however this is just from reverse engineering it in my head on the fly, so i have no idea if im on the right track or not. if you arent updating the client, you dont need to use startTransition (per docs). Updating the client includes doing any of redirect, revalidatePath, or revalidateTag. If we ARE updating state, and therefore updating the client, this inherently means we are manipulating the client state in some way, since our UI is changing after the server action is complete. In react, we use startTransition to start non-blocking state updates, so in theory, if you use a server action & dont wrap it in startTransition, your UI would completely block untill the server action is done. Since this is not what we want, we tell react to let the client continue to update and move around while the server is processing the request by wrapping it in the startTransition.
0 Replies
No replies yetBe the first to reply to this messageJoin