React lifecycle hook that call mount and unmount callbacks, when component is mounted and un-mounted, respectively.

💡 Implementation
Pretty
Copy
const useLifecycles = (mount, unmount) => {
useEffect(() => {
if (mount) mount();
return () => {
if (unmount) unmount();
};
}, []);
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
🚀 Usage
Pretty
Copy
function Demo() {
useLifecycles(() => console.log("MOUNTED"), () => console.log("UNMOUNTED"));
return null;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
⚡Preview
🚨 console
["MOUNTED"]
Contributors