Debounce a mutation, but not optimistic update?
Hello! Working on a document editor where the contents of the document affects other parts of the app. Trying to get it so that as people type the immediate optimistic update runs and the rest of the app can adjust, but not actually post the mutation on every keystroke. What's the best way to do this?
1 Reply
ugly-tan•4y ago
Not super familiar with the intricacies of React Query, but from what I know React Query is used to manage server state and fetching of data.
I would useState on that and pass state around that way, and then either when the user is done or clicks save, make the mutation based on that.
You can access the effects of typing into a box by passing event into the function of whatever you're doing. Usually event.target.value will give you the current value of your box.
React Query might be able to handle this and obviously that would be preferred.