import { useQueries } from '@tanstack/react-query';
import { getGeometriesByCatchmentId } from 'src/actions/globalFetchers';
export const useGeometriesList = (mapId: number, catchmentId: number[]) => {
// the list of catchemntId can be 100 or more ids
const queries = catchmentId.map((id) => ({
queryKey: ['geometries', id],
queryFn: () => getGeometriesByCatchmentId(mapId, id),
enabled: !!mapId || mapId !== 0,
refetchOnWindowFocus: false,
}))
const query = useQueries({
queries: queries,
})
return {
query,
}
};
import { useQueries } from '@tanstack/react-query';
import { getGeometriesByCatchmentId } from 'src/actions/globalFetchers';
export const useGeometriesList = (mapId: number, catchmentId: number[]) => {
// the list of catchemntId can be 100 or more ids
const queries = catchmentId.map((id) => ({
queryKey: ['geometries', id],
queryFn: () => getGeometriesByCatchmentId(mapId, id),
enabled: !!mapId || mapId !== 0,
refetchOnWindowFocus: false,
}))
const query = useQueries({
queries: queries,
})
return {
query,
}
};