Mutation optimistic updated slows down the UI
I have an app in which a user can upload files and then interact with them - add to favorite, change display name, etc..
One of the functionalities is to delete a file.
I use tanstack mutation to do optimistic updates for the files deletion - all the files are inside a table.
There is nothing special in this specific example.
When a user click the button the
onMutate
function fires and it filters the files to remove the file id.
The problem it that is slows down the UI, not by a lot of course but in some sense.
I've added a video for reference - in this video I have around 200 files that it filter.
I'd appreciate any answer and if it is a problem at all.2 Replies
rival-black•2y ago
My guess is that tanstack isn't to blame here. Either invalidating the queryKey causes too much work (too many http reqs etc.) or your UI code is re-rendering all 200 files when it shouldn't be. Without the UI code or useQuery(<fileKey>,...) it's impossible to tell anymore
mute-goldOP•2y ago
This the the
useQuery