Complete the code to import the main hook from React Query.
import { [1] } from '@tanstack/react-query';
The useQuery hook is the main React Query hook used to fetch data.
Complete the code to fetch data from the API endpoint using useQuery.
const { data, isLoading } = useQuery(['todos'], () => fetch('[1]').then(res => res.json()));The URL 'https://api.example.com/todos' is the correct API endpoint to fetch todos.
Fix the error in the code by completing the missing option to enable refetching on window focus.
const { data, refetch } = useQuery(['user'], fetchUser, { refetchOnWindow[1]: true });The option refetchOnWindowFocus enables React Query to refetch data when the window gains focus.
Fill both blanks to create a query key and a fetch function for React Query.
const { data } = useQuery([[1]], () => fetch([2]).then(res => res.json()));The query key 'posts' matches the API endpoint 'https://api.example.com/posts' to fetch posts data.
Fill all three blanks to destructure data, loading state, and error from useQuery.
const { [1], [2], [3] } = useQuery(['profile'], fetchProfile);React Query returns data, isLoading, and error to handle fetched data, loading state, and errors.