Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

17 righe
412 B

  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. * @category effects
  8. */
  9. export default function useWillUnmount(fn) {
  10. var onUnmount = useUpdatedRef(fn);
  11. useEffect(function () {
  12. return function () {
  13. return onUnmount.current();
  14. };
  15. }, []);
  16. }