You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have switch which toggle value using useServerAction.
Everything works great but when using optimistic update the data becomes undefined for moment when switching from optimistic value to server returned value. Resulting in bad flicker of the switch.
In my client component I have folowing console log:
console.log("data: ", data, "isOptimistic: ", isOptimistic, "status:", status);
This prints when I flip the switch:
data: true isOptimistic: false status: success
data: true isOptimistic: true status: pending
This prints after server action request returns:
data: undefined isOptimistic: false: status pending
data: true isOptimistic: false status: success
data: undefined, isOptimistic: false is the problem because switch doesnt know what value to show.
It is fixed immedialy with: data: true, but quick flicker is anoying.
I believe data should get the optimistic value until isOptimistic is false.
The text was updated successfully, but these errors were encountered:
I have switch which toggle value using useServerAction.
Everything works great but when using optimistic update the data becomes undefined for moment when switching from optimistic value to server returned value. Resulting in bad flicker of the switch.
In my client component I have folowing console log:
console.log("data: ", data, "isOptimistic: ", isOptimistic, "status:", status);
This prints when I flip the switch:
data: true isOptimistic: false status: success
data: true isOptimistic: true status: pending
This prints after server action request returns:
data: undefined isOptimistic: false: status pending
data: true isOptimistic: false status: success
data: undefined, isOptimistic: false is the problem because switch doesnt know what value to show.
It is fixed immedialy with: data: true, but quick flicker is anoying.
I believe data should get the optimistic value until isOptimistic is false.
The text was updated successfully, but these errors were encountered: