But data is not updating automatically. What is the likely cause?
medium
A. The component is unmounted or paused
B. The pollInterval value is too low
C. The query is missing a refetch call
D. Polling requires manual trigger each time
Solution
Step 1: Understand polling requirements
Polling runs only when the component is mounted and active.
Step 2: Check common issues
If data is not updating, the component might be unmounted or React Suspense is pausing it.
Step 3: Eliminate other options
Polling does not need manual refetch, and 3000 ms is valid.
Final Answer:
The component is unmounted or paused -> Option A
Quick Check:
Polling requires active component [OK]
Hint: Polling only works if component is mounted and active [OK]
Common Mistakes:
Thinking polling needs manual refetch
Assuming pollInterval too low stops polling
Ignoring component lifecycle
5. You want to keep a chat app's messages updated. You use polling every 15 seconds but also want users to refresh manually. Which approach best combines refetching and polling?
hard
A. Use polling with pollInterval: 15000 and disable manual refresh
B. Use only refetching triggered by a button every 15 seconds
C. Use refetching inside a setInterval instead of polling
D. Use polling with pollInterval: 15000 and add a button that calls refetch()
Solution
Step 1: Understand polling and manual refresh
Polling updates data automatically every 15 seconds.
Step 2: Add manual refresh
Adding a button that calls refetch() lets users update data on demand.
Step 3: Evaluate options
Use polling with pollInterval: 15000 and add a button that calls refetch() combines both correctly; others either disable manual refresh or misuse refetching.
Final Answer:
Use polling with pollInterval: 15000 and add a button that calls refetch() -> Option D
Quick Check:
Polling + manual refetch button = best combo [OK]
Hint: Combine pollInterval with refetch button for best updates [OK]