Hooks
/ API ReferenceHooks
/ API ReferenceuseFirstRender
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.
© 2024-present Robin Weser. All Rights Reserved.