usePrevious

Allows access to the previous value in state.


import { usePrevious } from 'primereact/hooks';
         

Previous value remains one step behind the current value while input is being typed.

Current: Previous:

const [value, setValue] = useState('');
const prevValue = usePrevious(value);
         
Summer Sale 2025
SUMMER SALE2025
Use coupon code PRSM25 at checkout to get 50% OFF everything in PrimeStore and PrimeBlocks.
Learn More