# OptimisticRollback

Defined in: [react/src/types.ts:307](https://github.com/B3Pay/ic-reactor/blob/f1956947ae037304fce1675a38695964c1aa9e32/packages/react/src/types.ts#L307)

What `optimisticUpdate()` resolves with: the way back to the value the
cache held before the update.

## Example

```typescript
const update = await postQuery.optimisticUpdate((post) => ({
  ...post,
  likes: post.likes + 1n,
}))
// The call failed: show the post as it was
update.rollback()
```

## Properties

### rollback

> **rollback**: () => `void`

Defined in: [react/src/types.ts:320](https://github.com/B3Pay/ic-reactor/blob/f1956947ae037304fce1675a38695964c1aa9e32/packages/react/src/types.ts#L320)

Write back the value the cache held before the update, with the time it
was fetched, so it is as fresh or as stale as it was. A value that was
invalidated is invalidated again, so a mounted query refetches it, as
the refetch the update cancelled would have.

It does nothing when the update wrote nothing, or when another principal
has signed in or out since: the value was the previous principal's, and
the sign-in has already removed or refetched it. It restores that value
even if a fetch or another update has written since; invalidate the
query afterwards when the canister's current value matters.

#### Returns

`void`