Next14 + react-query + server actions: Deleting item from a table but the table should self-adjust
here's my
deleteCategoryMutation
Let's say we have 12 items max on a table and I delete 1
The table should:
1. Not display the deleted item
2. Get the next item from the next page and put it on the last slot
The reason I invalidate the query is because no data is returned from deleteCategory
and the updated list comes from categories
however after invalidating it doesn't refresh the UI
Here's how it's setup
here's MainCategoriesModule
Am I missing something or should I just use setQueryData
and fetch the next page and then stitch it? It seems like a waste since the categories
query already has the fresh data just need to reload the UI. window.reload()
feels bad to use.
also the backend does the work to fix the pagination which is why I said setQueryData
seems like a waste0 Replies