1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| const { data, error, status, refetch, fetchStatus, isFetching, isLoading, isError, isSuccess} = useQuery(['todos'], fetchTodoList)}
useQuery(['todo', todoId, { preview: true }], ...)
useQuery(['todos', {status, page}, async ({ queryKey, pageParam, signal?: AbortSignal }) => { const [_key, { status, page }] = queryKey return new Promise() }])
const { status, fetchStatus, data: projects } = useQuery( ['projects', userId], getProjectsByUser, { enabled: !!userId, refetchOnWindowFocus: false, retry : false, retry: 6, notifyOnChangeProps: string[] | "all" retry: (failureCount, error) => {}, retryDelay: attemptIndex => Math.min(1000 * 2 ** attemptIndex, 30000), keepPreviousData: true, initialData: [], initialDataUpdatedAt: 1234567890, initialData: () => { return getExpensiveTodos() }, initialData: () => { return queryClient.getQueryData(['todos'])?.find(d => d.id === todoId) }, placeholderData: [], placeholderData: useMemo(() => generateFakeTodos(), []), placeholderData: () => { return queryClient .getQueryData(['blogPosts']) ?.find(d => d.id === blogPostId) }, staleTime: 1000, refetchInterval: 6000, } )
|