Shuffle array in dependent query forever loop
Hi guys, I have this query:
Withouth the shuffle, everything is OK.
But if I ad the shuffle to similarVariantIds array, it load forever.
How can I fix this?
1 Reply
extended-salmon•3y ago
Hi there.
The order of items in the array matters, so when RQ stringifies
similarVariantIds to use it as a queryKey by using shuffleArray you will get different results each time. This means that every time the query will re-run. You might consider making similarVariantIds an object instead of an array. This should solve your problem
Also I don't know your case but it looks to me that your useQuery should use queryKey: ["similarProducts", selectedIds], as it only depends on selectedIds