usePreviousstate
usePrevious
NewSSR SAFEStores previous value of a state or prop across renders.
$ pnpm dlx shadcn@latest add @byphongphan/use-previousRequires
@byphongphan in components.jsonuse-previous.tsx
Loading preview...
Installation
$ pnpm dlx shadcn@latest add @byphongphan/use-previousRequires
@byphongphan in components.jsonUsage
Props & Parameters
| Param | Type | Default | Description |
|---|---|---|---|
value | T | — | Any state or prop value to track across render cycles. |
Returns
| Return | Type | Description |
|---|---|---|
previousValue | T | undefined | The value from the previous render cycle, or undefined on the initial mount. |