T
TanStack•3y ago
exotic-emerald

Is array in query key array compared by value or reference? useQuery, v3

Would the following query key be the same?
const a = [1,2];
const b = [1,2];
useQuery(['todos', a], ...)
useQuery(['todos', b], ...)
const a = [1,2];
const b = [1,2];
useQuery(['todos', a], ...)
useQuery(['todos', b], ...)
Thank you!
3 Replies
unwilling-turquoise
unwilling-turquoise•3y ago
Yes
exotic-emerald
exotic-emeraldOP•3y ago
@TkDodo 🔮 Thank you! @TkDodo 🔮 https://codesandbox.io/s/hardcore-worker-t308yo?file=/src/index.js Do you know why using queryB would also update data of queryA?
exotic-emerald
exotic-emeraldOP•3y ago
Actually I found the answer, I should pass exact:true for my case, https://tanstack.com/query/v3/docs/react/guides/filters
Filters | TanStack Query Docs
Some methods within React Query accept a QueryFilters or MutationFilters object. Query Filters

Did you find this page helpful?