Commit 05ccb3c
authored
fix: correct query key format in newNoteMutation onSuccess handler
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 070deb3 commit 05ccb3c
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
382 | | - | |
383 | | - | |
| 382 | + | |
| 383 | + | |
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| |||
0 commit comments