UNPKG

rooks

Version:

Essential React custom hooks ⚓ to super charge your components!

17 lines (16 loc) 454 B
import { useEffect } from "react"; /** * useWillUnmount hook * Fires a callback just before component unmounts * * @param {Function} callback Callback to be called before unmount * @see https://react-hooks.org/docs/useWillUnmount */ function useWillUnmount(callback) { // run only once useEffect(function () { return callback; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); } export { useWillUnmount };