Skip to main content

useLifecycle

Creates a React.RefObject that is constantly updated with the incoming value.

API

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

Usage

import { useLiveRef } from '@jtmdias/js-utilities';

function Component({ prop }) {
const PROP_REF = useLiveRef(prop);
}