Mantle UI icon

usePrevious

Allows access to the previous value in state.


import { usePrevious } from '@mantle-ui/react/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);