useIsFirstRender

Check if it's the first render.

https://www.shaktools.com/shak-hooks
Utility

API Reference

Installation

terminal
pnpm add @shak-hooks/usehooks
import.ts
import { useIsFirstRender } from "@shak-hooks/usehooks";
Source: packages/react/src/useIsFirstRender.ts

Signature

signature.ts
export function useIsFirstRender()

Parameters

No parameters.

Returns

unknown

Implementation

use-is-first-render.ts
1import { useRef } from "react";
2
3export function useIsFirstRender(): boolean {
4 const isFirst = useRef(true);
5
6 if (isFirst.current) {
7 isFirst.current = false;
8 return true;
9 }
10
11 return false;
12}

Advertisement

Google Ads

Usage

example.tsx
1import { useIsFirstRender } from "@shak-hooks/usehooks";
2
3const result = useIsFirstRender();
4// result: unknown
5// Use values directly (React state).

Let‘s do great work together

Empowering creators with free, high-performance AI, SEO, and developer tools. Join thousands of users optimizing their workflow with Shak-Tools.

Tools10+ Free
UsersGlobal

Stay in the loop

Join our newsletter for the latest AI tools and updates.

ShakTools
© 2025 Shaktools. All Rights Reserved.Privacy Policy