Commit 30caf0f
authored
Update queryClient calls to use array keys
The useQuery hook uses an array format for queryKey (['notes']), but the
mutation's getQueryData and setQueryData calls were using a string format
('notes'). In TanStack Query v4+, these are treated as completely different
cache keys, preventing the optimistic cache update from working.
This caused the UI to not update after adding a new note because the mutation
was updating a different cache entry than the one being watched by useQuery.
Changed queryClient.getQueryData('notes') to queryClient.getQueryData(['notes'])
and queryClient.setQueryData('notes', ...) to queryClient.setQueryData(['notes'], ...)
to ensure cache consistency and proper UI updates.1 parent 05ccb3c commit 30caf0f
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
384 | | - | |
| 383 | + | |
| 384 | + | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
| |||
0 commit comments