Polling
Refetching on a timer to notice changes the server does not push. With refetchInterval as a function, the app polls an order only while its screen is focused and stops once the order is final. WebSockets replace it in week 5.
Minimal example
refetchInterval: query => (focused ? pollInterval(query.state.data) : false)Learn this concept
Lesson 4.8 · TanStack Query cachingUsed in exercises
Exercise 4.17 · Orders tab and order detail screens Exercise 5.5 · Per-user order event bridge Exercise 5.12 · Rider mode and customer tracking screensPrerequisite conceptsTanStack Query