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

NameTypeDescriptionDefault
valueanyAny value to track.-

Returns

NameDescription
previousThe 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.
Saha UI - The Modern React Component Library