usePrevious ​
A Hook to return the previous state.
Basic usage ​
Custom shouldUpdate function ​
Result ​
| Property | Description | Type |
|---|---|---|
| previousRef | The previous value | Readonly<Ref<T>> |
Params ​
| Property | Description | Type | Default Value |
|---|---|---|---|
| currentRef | The state that needs to be tracked | Ref<T> | ComputedRef<T> | - |
| shouldUpdate | Optional. Customize whether the state value should be updated | (prev: T | undefined, next: T) => boolean | (a, b) => a !== b |