usePrevious
API
import usePrevious from '@restart/hooks/usePrevious'
usePrevious
<T>(value: T) => T | nullStore the last of some value. Tracked via a
Ref
only updating it after the component renders. Helpful if you need to compare a prop value to it's previous value during render.function Component(props) {const lastProps = usePrevious(props)if (lastProps.foo !== props.foo)resetValueFromProps(props.foo)}Parameters
value
Tthe value to track
Return Value T | null