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
increment the quantity count by clicking as fast as possible 50 times in a row
try to click outside the cart and navigate to another page
It'll take a while before navigation occurs (while the server actions is being processed).
useOptimistic is not great for incrementing quantity, as you can't easily debounce server actions as far as I know. Meaning if you click to increment quantity e.g. 50 times, you'll queue and execute 50 server actions after each other.
That can be reduced to just 1 server action call if you do it manually with useState and debounce of e.g. 300-400ms.
The text was updated successfully, but these errors were encountered:
I'm not sure why this has not been mentioned yet:
It'll take a while before navigation occurs (while the server actions is being processed).
useOptimistic is not great for incrementing quantity, as you can't easily debounce server actions as far as I know. Meaning if you click to increment quantity e.g. 50 times, you'll queue and execute 50 server actions after each other.
That can be reduced to just 1 server action call if you do it manually with useState and debounce of e.g. 300-400ms.
The text was updated successfully, but these errors were encountered: