Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usePrevious.d.ts 472B

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