Hooks
/ API Reference
Hooks
/ API Reference

useFirstRender

A hook that returns a boolean indicating whether the component is rendering for the first time.

The Gist

'use client'
import { useFirstRender } from '@weser/hooks'

function Component() {
  const isFirstRender = useFirstRender()

  useEffect(() => {
    if (isFirstRender) {
      console.log('This is the first render.')
    }
  }, [isFirstRender])

  return <div>Lorem ipsum.</div>
}

Returns

(boolean) A boolean indicating whether the component is rendering for the first time.

On this page