@react-hookz/web
Version:
React hooks done right, for browser and SSR.
14 lines (13 loc) • 369 B
JavaScript
import { useEffect } from 'react';
/**
* Run effect only when component is first mounted.
*
* @param effect Effector to run on mount
*/
export function useMountEffect(effect) {
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
effect();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
}