1 | /**
|
2 | * Store the last of some value. Tracked via a `Ref` only updating it
|
3 | * after the component renders.
|
4 | *
|
5 | * Helpful if you need to compare a prop value to it's previous value during render.
|
6 | *
|
7 | * ```ts
|
8 | * function Component(props) {
|
9 | * const lastProps = usePrevious(props)
|
10 | *
|
11 | * if (lastProps.foo !== props.foo)
|
12 | * resetValueFromProps(props.foo)
|
13 | * }
|
14 | * ```
|
15 | *
|
16 | * @param value the value to track
|
17 | */
|
18 | export default function usePrevious<T>(value: T): T | null;
|