useQuery helper functions to access returned data?
So we have an API request that fetches two large maps. We have many helper functions like this across the app, keeping the large maps in one scope but importing these util functions around. We are in the process of making this API fetch to useQuery and stuck wondering whats the best way to return helper functions that access that data?
5 Replies
exotic-emerald•4y ago
I'd use select.
genetic-orangeOP•4y ago
My understanding is select would mutate the data every time you try to access it. Is that right and the idea approach? To recreate these helper functions many times?
exotic-emerald•4y ago
Not sure what you mean with "mutate"? Select should work in an immutable way and just return stuff..
genetic-orangeOP•4y ago
ah Okay. Is it safe to assume that lets say I use this query in many different components. When there is fresh data refresh, would all components have the most recent version of these helper methods return from select?
exotic-emerald•4y ago
Yes? I don't fully understand what you're trying to do