TanStackT
TanStack14mo ago
7 replies
ill-bronze

When to use select vs other options for displaying subset of data?

Scenario: I want to toggle between displaying data1, data2, and combinedData.

I'm just getting started with react query and trying to understand what is the right approach:
1. useQuery to get the combinedData comprising of data1 and data2, use select to filter to data1 or data2 as needed
2. useQuery passing an argument to the queryFn to decide which dataset to fetch
3. have a useQuery for data1 and another useQuery for data2, conditionally render one or the other or the two combined

I'm thinking option 1 is the optimal thing to do, but are these all viable approaches?
Was this page helpful?