#Best way to handle combining 2 data objects.

5 messages · Page 1 of 1 (latest)

normal lintel
#

Hi, so my question has to do with combining 2 separate fetched data objects. The current solution I have right now is I create a local state and then set that local state a new custom object containing the 2 fetched data objects from react query. I was wondering instead of doing this hack, is there a way to directly handle combining 2 data objects into 1, straight from react query without having to rely on creating a local state.

lethal roost
#

Hi you could define 2 queryKey/queryFn couples for your objects and a third one which would combine the results of the other queryFns. This way you could use useQuery for object 1 or object 2 while still being able to have the combination of both. All of this would rely on cached data.

normal lintel
#

Ok ty I'll look into it!

lethal roost
normal lintel
#

ty!