React Query · question
Q.03 of 49
Explain the basic structure of a `useQuery` hook
← All React Query questions
Re-explain
The useQuery hook accepts a configuration object with key properties:
const { data, isLoading, error, isError, isSuccess } = useQuery({
queryKey: ['posts', userId], // Unique identifier for the query
queryFn: () => fetchPosts(userId), // Function that returns a promise
enabled: !!userId, // Optional: conditionally enable the query
staleTime: 5 * 60 * 1000, // Optional: how long data stays fresh
refetchOnWindowFocus: false // Optional: disable refetch on window focus
});
Key properties:
queryKey: Unique identifier used for caching and invalidation
queryFn: Async function that fetches the data
enabled: Boolean to conditionally run the query
staleTime: Time in milliseconds before data is considered stale
Return values:
data: The fetched data
isLoading: True during the first fetch
error: Error object if the query failed
isError/isSuccess: Boolean states for handling different scenarios
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
The model's verdict: “”
This answer is explained by a shared concept diagram -
open →
Point the redraw:
How well did you know this?
AI:
Saved in this browser - sign in to keep your review list.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Keep going - a few more words and AI can grade it.
Interview lens
Likely follow-ups, what you can say, and the weak answers to avoid.
Pro · $10/mo
42 of 49 React Query answers are gated.
Full answers, code samples, AI explanations - simpler, deeper, or as an interactive diagram. Cancel anytime.
-
Full answers + code
-
AI explain - simpler, deeper, or visualized
-
1,000 AI credits / month
-
Cancel anytime