React · Junior · Question 48 of 75
What must you pass to useQuery?
- 1
url,methodandheaders - ✓Correct answer:
queryKeyandqueryFn - 3
store,reducerandaction
Explanation
useQuery({ queryKey: ['todos', id], queryFn: () => fetchTodo(id) }). The key identifies data in the cache: everything the request depends on must be in the key - then the request reruns when id changes. queryFn is any function returning a promise; the library isn't tied to fetch.