Redux & Redux Toolkit
/Intermediate
Polling & Refetching
Definition
Features in RTK Query that allow data to be automatically refetched from the server based on time intervals, window focus events, or network reconnection.
Explain Like I'm New
Some data changes constantly, like a live sports score or a stock ticker. RTK Query can be told: 'Automatically fetch this endpoint every 3 seconds' (Polling), or 'Refetch this data every time the user clicks back to this browser tab' (Refetch on Focus).
Real World Example
A cryptocurrency dashboard. You set `pollingInterval: 5000` on the Bitcoin price query. Without writing a single `setInterval` or `useEffect`, the price updates automatically every 5 seconds.
Common Use Cases
- •Live dashboards
- •Keeping stale data fresh
- •Mobile-style background fetching
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- What option do you pass to a query hook to make it fetch every 10 seconds?
intermediate
- Why is `refetchOnFocus` useful for web applications?