React · Junior · Question 48 of 75

What must you pass to useQuery?

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.

Further reading

Problem with a question

React · Junior · question 48

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz