State Management · Middle · Question 62 of 75
What does the queryOptions helper give you?
export const todoQuery = (id: number) =>
queryOptions({ queryKey: ["todo", id], queryFn: () => fetchTodo(id) });
useQuery(todoQuery(5));
queryClient.prefetchQuery(todoQuery(5));- ✓Correct answer: Reusable, type-safe query definitions shared between hooks, prefetching and cache reads
- 2Global default options for all queries
- 3Server-only queries
Explanation
Keys and functions stay together, and queryClient.getQueryData(todoQuery(5).queryKey) gets the right data type automatically.