Skip to content

Commit

Permalink
docs(optimistic-updates): ease wording in introduction (#2908)
Browse files Browse the repository at this point in the history
  • Loading branch information
BerniWittmann committed Nov 11, 2021
1 parent 8065a7e commit 3534621
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/src/pages/guides/optimistic-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: optimistic-updates
title: Optimistic Updates
---

When you optimistically update your state before performing a mutation, there is a non-zero chance that the mutation will fail. In most cases, you can just trigger a refetch for your optimistic queries to revert them to their true server state. In some circumstances though, refetching may not work correctly and the mutation error could represent some type of server issue that won't make it possible to refetch. In this event, you can instead choose to rollback your update.
When you optimistically update your state before performing a mutation, there is a chance that the mutation will fail. In most of these failure cases, you can just trigger a refetch for your optimistic queries to revert them to their true server state. In some circumstances though, refetching may not work correctly and the mutation error could represent some type of server issue that won't make it possible to refetch. In this event, you can instead choose to rollback your update.

To do this, `useMutation`'s `onMutate` handler option allows you to return a value that will later be passed to both `onError` and `onSettled` handlers as the last argument. In most cases, it is most useful to pass a rollback function.

Expand Down

1 comment on commit 3534621

@vercel
Copy link

@vercel vercel bot commented on 3534621 Nov 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.