···1010tag: engineering
1111---
12121313-While TanStack provides excellent [documentation on Infinite Queries](https://tanstack.com/query/latest/docs/framework/react/guides/infinite-queries), this article offers an additional practical example focusing on implementing live data updates.
1313+This article is part of the [logs.run](https://logs.run) series. You can enable the live mode right away via [logs.run/i?live=true](https://logs.run/i?live=true).
1414+1515+While TanStack provides excellent documentation on [Infinite Queries](https://tanstack.com/query/latest/docs/framework/react/guides/infinite-queries), this article offers an additional practical example focusing on implementing live data updates.
14161517## Basic Concept
1618···2628);
2729```
28302929-
3030-3131Once we understand the _load more_ (append data) functionality, we can mirror this approach to implement _live mode_ (prepend data).
32323333Each query requires two key parameters:
343435351. A `cursor` - a pointer indicating a position in the dataset
36362. A `direction` - specifying whether to fetch data before or after the cursor ("prev" or "next")
3737+3838+
37393840In our implementation, the `cursor` is a timestamp representing the last checked date:
3941···166168```
167169168170We use `setTimeout` with recursion rather than `setInterval` to ensure each refresh only starts after the previous one completes. This prevents multiple simultaneous fetches when network latency exceeds the refresh interval and is a better UX.
171171+172172+---
173173+174174+Now check it out on [logs.run/i?live=true](https://logs.run/i?live=true).
169175170176For more details about our data table implementation, check out [The React data-table I always wanted](https://www.openstatus.dev/blog/data-table-redesign).