UNPKG

@react-hookz/web

Version:

React hooks done right, for browser and SSR.

12 lines (11 loc) 295 B
import { useEffect, useRef } from 'react'; /** * Return boolean that is `true` only on first render. */ export function useFirstMountState() { var isFirstMount = useRef(true); useEffect(function () { isFirstMount.current = false; }, []); return isFirstMount.current; }