Function
useUserInfoQuery
({
id,
enabled,
}: {
id: number | null
enabled: boolean
})
Source from the content-addressed store, hash-verified
| 2017 | const key = queryKey() |
| 2018 | |
| 2019 | const useUserInfoQuery = ({ |
| 2020 | id, |
| 2021 | enabled, |
| 2022 | }: { |
| 2023 | id: number | null |
| 2024 | enabled: boolean |
| 2025 | }) => { |
| 2026 | return useQuery({ |
| 2027 | queryKey: [key, id], |
| 2028 | queryFn: async () => { |
| 2029 | await sleep(10) |
| 2030 | return { id, name: 'John' } |
| 2031 | }, |
| 2032 | enabled: !!id && enabled, |
| 2033 | }) |
| 2034 | } |
| 2035 | |
| 2036 | const Page = () => { |
| 2037 | const [id, setId] = React.useState<number | null>(null) |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…