Skip to Content
ohooks

useFirstMountState

Returns true during the initial render of a component and false on all subsequent renders.

Loading preview...

The useFirstMountState hook returns a boolean indicating whether the component is currently executing its very first render pass.

Installation

pnpm dlx shadcn@latest add https://ohooks.vercel.app/r/useFirstMountState.json

Usage

Examples

Skipping Entrance Animations on Initial Render

Check isFirstMount to render the initial UI without transition classes and enable animations only on subsequent state changes.

Distinguishing Mount from Updates

Combine isFirstMount with state or props to log or react differently after the first render.