useQuery를 여러개 실행할 때 사용
const result = useQueries({
queries: [
{
queryKey: ['mypageUser'],
queryFn: () => getUserData(),
refetchOnWindowFocus: false,
onError: (err: unknown) => {
console.log('mypageUser2', { err })
},
},
{
queryKey: ['mypageUserList'],
queryFn: () => getUserListData(),
refetchOnWindowFocus: false,
onError: (err: unknown) => {
console.log('mypageUserList', { err })
},
},
],
})
const getUserData = async () => {
const {
data: { data },
} = await AxiosApi.get('/user-info')
setCompany(data.company)
setUser(data)
return data
}
useEffect(() => {
const loadingFinishAll = result.some((result) => result.isLoading)
},[result])