Dashboard sipadu mbip
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

useWillUnmount.js 391B

12345678910111213141516
  1. import useUpdatedRef from './useUpdatedRef';
  2. import { useEffect } from 'react';
  3. /**
  4. * Attach a callback that fires when a component unmounts
  5. *
  6. * @param fn Handler to run when the component unmounts
  7. */
  8. export default function useWillUnmount(fn) {
  9. var onUnmount = useUpdatedRef(fn);
  10. useEffect(function () {
  11. return function () {
  12. return onUnmount.current();
  13. };
  14. }, []);
  15. }