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.

useMounted.d.ts 624B

123456789101112131415161718192021
  1. /**
  2. * Track whether a component is current mounted. Generally less preferable than
  3. * properlly canceling effects so they don't run after a component is unmounted,
  4. * but helpful in cases where that isn't feasible, such as a `Promise` resolution.
  5. *
  6. * @returns a function that returns the current isMounted state of the component
  7. *
  8. * ```ts
  9. * const [data, setData] = useState(null)
  10. * const isMounted = useMounted()
  11. *
  12. * useEffect(() => {
  13. * fetchdata().then((newData) => {
  14. * if (isMounted()) {
  15. * setData(newData);
  16. * }
  17. * })
  18. * })
  19. * ```
  20. */
  21. export default function useMounted(): () => boolean;