This example demonstrates how to implement infinite loading with React Query'suseInfiniteQuery hook. Additionally, it showcases mutations, updating the query cache after a mutation, and optimistic updates.
Try posting a new comment or click the 'Load More' button
Loading comments...
data.pageshasNextPage and isFetchingNextPageOptimistic updates provide a better user experience by immediately updating the UI before the server confirms the change. The server in this demo has a 10% chance of randomly returning an error to demonstrate the rollback behavior.