State Management
usePrevious
Track and access the previous value of a state or prop across renders.
import { usePrevious } from "saha-ui"Uses
Remember the previous render value for comparisons or animations.
Props
| Name | Type | Description | Default |
|---|---|---|---|
| value | any | Any value to track. | - |
Returns
| Name | Description |
|---|---|
| previous | The value from the previous render (or `undefined` on first render). |
Example
const prevCount = usePrevious(count);
Notes
Very small utility built on a ref updated in an effect.