Dashboard sipadu mbip
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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;