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);