TanStackT
TanStack3y ago
33 replies
colossal-harlequin

nested mutability - setQueryData

I understand that the top level data must be updated in an immutable way (spreading object, array or otherwise returning a reference to a new object !== old reference.).
But, say I have an array of arrays - should there be any reason that once I have a new reference in hand (
.filter
ed from oldData with one top level array filtered out, say) - setQueryData should work if I then update one of the underlying arrays, right?
Meaning - does setQueryData need to be immutable all the way down, or just the top level (structuralSharing is off)? I assume its the latter, but I'm hitting strange behavior where I create a new reference, and then mutate a child, but the query data doesn't update.
Was this page helpful?