State Management · Junior · Question 62 of 75
Which fields of a useQuery result do you usually render from?
const { data, error, isPending, isError } = useQuery({ queryKey: ["todos"], queryFn });- ✓Correct answer:
isPendingfor the first load,isError/errorfor failures anddatawhen it's ready - 2Only
data; errors are thrown to the console - 3
loadingandresult
Explanation
status is 'pending' | 'error' | 'success'. Checking it first lets TypeScript narrow data to a defined value in the success branch.