Skip to main content

useLifecycle

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

API

function useLifecycle(mount: () => void, unmount?: () => void): void;

Usage

import { useLifecycle } from '@feedzai/js-utilities/hooks';

useLifecycle(
() => console.log('runs on mount'),
() => console.log('runs on unmount'),
);