UNPKG

@react-hookz/web

Version:

React hooks done right, for browser and SSR.

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