setQueryData doesn't change cache reference #1272
Replies: 1 comment 1 reply
-
Hi, I think you are experiencing an actual feature of react-query called
So, this is on purpose to avoid unnecessary re-renders. If nothing really changes (except for the object reference), why re-render? Of course, you can turn that setting off via |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In the above code the query data cache doesn't change the variable reference (even with
{...prev}
) what cause useMemo dependencies not to triggerIf I change the dependency to
[JSON.stringify(data)]
it solve the problem but I think that it can cause to performance problem when the data is huge.Beta Was this translation helpful? Give feedback.
All reactions