import { useQuery } from 'react-query' ; import { getArea , AreaRes } from '../api' ; async function fetchArea ( { queryKey } ) { const [ _key , areaId ] = queryKey ; return await getArea ( areaId ) ; } export function useArea ( areaId ? ) { return useQuery ( areaId && [ 'areas' , areaId ] , fetchArea ) ; }