Theo's Typesafe CultTTC
Theo's Typesafe Cult•2y ago•
3 replies
Zefty

Anyone familiar with useOptimistic hook to explain how it works???

Hey everyone, im currently using the t3 stack with Next.js app router and have trying to get the useOptimistic hook alongside a server action working

So far I have managed to get this all working correctly with one caveat: I have to put "revalidatePath("<url here>")" as the very last line in my server action in order for the hook to work.

If I don't do this, the UI flashes for a brief moment and resets back to the "old state" (in my case the button flashes from filled back to unfilled)
Was this page helpful?