Skip to content

Commit

Permalink
docs: Update optimistic-updates.md (TanStack#731)
Browse files Browse the repository at this point in the history
Minor fixes in code examples
  • Loading branch information
eddydg authored Jul 10, 2020
1 parent de15f61 commit 58f245f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/src/pages/docs/guides/optimistic-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ useMutation(updateTodo, {
queryCache.cancelQueries(['todos', newTodo.id])

// Snapshot the previous value
const previousTodo = queryCache.getQueryData(['todos', newTodo.id], newTodo)
const previousTodo = queryCache.getQueryData(['todos', newTodo.id])

// Optimistically update to the new value
queryCache.setQueryData(['todos', newTodo.id], newTodo)
Expand All @@ -55,7 +55,7 @@ useMutation(updateTodo, {
// If the mutation fails, use the rollback function we returned above
onError: (err, newTodo, rollback) => rollback(),
// Always refetch after error or success:
onSettled: () => {
onSettled: newTodo => {
queryCache.invalidateQueries(['todos', newTodo.id])
},
})
Expand Down

0 comments on commit 58f245f

Please sign in to comment.