-
Hello, I'm currently working on some sort of e-commerce site. Basically, we store client's cart on the backend and if a client wants to add an item, we send a mutation to check if the item is still available, then update the cart accordingly. Everything is handled by react-query: mutation to update the cart ==> cart query and item availability queries are invalidated and refetched. We have one issue: If someone spam clicks the
We think the second solution is interesting and we started giving some thought to it. But I have a feeling that we may be going against react-query. I didn't find much on the documentation / internet and I wanted to know if someone had already encountered that kind of issue before ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
yep, that's the easy way out, but UX is meh.
this is something I have done in a playground once (v2, very old, sorry), have a look here: https://codesandbox.io/s/sad-northcutt-syz0u it's basically just a debounce on the frontend on the value + a useEffect that then fires the real mutation. Maybe there is some way to make that with less code, like debounce the actual call to on top, if the user clicks + twice, then - twice, you don't have to fire a mutation at all. |
Beta Was this translation helpful? Give feedback.
yep, that's the easy way out, but UX is meh.
this is something I have done in a playground once (v2, very old, sorry), have a look here: h…