State Management · Middle · Question 57 of 75
How do you refetch an RTK Query every 30 seconds while the component is mounted?
- ✓Correct answer:
useGetStatsQuery(undefined, { pollingInterval: 30_000 }) - 2
setInterval(() => refetch(), 30_000)without cleanup - 3Add
refetch: 30to the endpoint
Explanation
Polling stops automatically on unmount. skipPollingIfUnfocused avoids requests in background tabs.