[]previous and next page

useOptimistic

useOptimistic(source, reducer) returns [state, apply].

For agentsUpdated

useOptimistic(source, reducer) returns [state, apply]. state() is source() with reducer applied once for each action whose promise is still pending. apply(action, promise) records an action; when promise settles, fulfilled or rejected, the action is dropped and state() falls back to the real source. A rejection is therefore a rollback. Give apply the promise that covers the whole operation, including the refetch that brings back the confirmed data.

The longer treatment, with polling and cache sharing, is in Data fetching.