Free ATS Friendly Resume Builder Online

Create Your Resume

Resume Builder

Resume Maker

Resume Templates

Resume PDF Download

Create Your Resume is a free online resume builder that helps job seekers create professional, ATS friendly resumes in minutes. Easily build, customize, and download modern resume templates in PDF format.

Our resume maker is designed for freshers and experienced professionals looking to create job-ready resumes. Choose from multiple resume templates, customize sections, and generate ATS optimized resumes online for free.

Create resumes for IT jobs, software developers, freshers, experienced professionals, managers, and students. This free resume builder supports CV creation, resume PDF download, and online resume editing without signup.

Back to React Js
Lesson 47 of 59

What Is React Strict Mode? How It Works Internally, Why React Intentionally Double-Invokes Code, and When You Should Use It

React Strict Mode is a development-only tool that helps developers identify unsafe lifecycle methods, unexpected side effects, legacy patterns, and future compatibility issues in React applications. It intentionally runs certain functions more than once to surface hidden bugs that may otherwise go unnoticed in production. While Strict Mode does not affect production builds, misunderstanding its behavior—especially double rendering, repeated effects, and unexpected logs—often confuses developers and leads to incorrect debugging conclusions. This guide explains what React Strict Mode is, how it works internally, why React double-invokes renders and effects, what problems it is designed to catch, common misconceptions, real-world production scenarios, and best practices for using Strict Mode effectively in modern React applications.

Why React Strict Mode Exists

As React applications grow, bugs caused by side effects, improper cleanup, and unsafe lifecycle usage become harder to detect. Many of these bugs do not break the app immediately but surface later in production under real user behavior.

React Strict Mode exists to intentionally expose these hidden problems during development, long before they reach users.

Large production systems such as complex React-driven platforms use Strict Mode to enforce safer and more future-proof code.

What Is React Strict Mode?

React Strict Mode is a development-only wrapper component that activates additional checks and warnings for its child component tree.

It does not:

  • Change production behavior
  • Add runtime overhead in production
  • Impact the final bundle

Its sole purpose is to help developers write better React code.

How to Enable React Strict Mode


import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";

const root = ReactDOM.createRoot(document.getElementById("root"));

root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

Strict Mode can be applied:

  • Globally (entire app)
  • Locally (specific component trees)

What React Strict Mode Actually Does

Strict Mode performs several intentional checks:

  • Double-invokes rendering functions
  • Double-invokes certain lifecycle methods
  • Double-runs effects in development
  • Warns about deprecated APIs
  • Detects unsafe side effects

This behavior is often misunderstood but is entirely intentional.

Why React Double-Renders Components in Strict Mode

One of the most confusing behaviors developers notice is components rendering twice in development.

This happens because React:

  • Renders the component
  • Immediately discards the result
  • Renders it again

This is done to verify that:

  • Rendering is pure
  • No side effects occur during render

Example: Impure Render Function


function Counter() {
  console.log("Rendered");
  return <div>Counter</div>;
}

In Strict Mode, this log appears twice. This helps identify side effects placed incorrectly in render.

Strict Mode and useEffect Double Invocation

In React 18+, Strict Mode intentionally runs useEffect twice during development:

  • Effect runs
  • Cleanup runs
  • Effect runs again

Why This Happens

This verifies that effects:

  • Have proper cleanup
  • Do not leak resources
  • Are resilient to re-mounting

Example: Missing Cleanup (Bug Revealed)


useEffect(() => {
  const interval = setInterval(() => {
    console.log("Polling...");
  }, 1000);
}, []);

This creates duplicate intervals in Strict Mode, revealing a serious production bug.

Correct Version


useEffect(() => {
  const interval = setInterval(() => {
    console.log("Polling...");
  }, 1000);

  return () => clearInterval(interval);
}, []);

This pattern is essential in flows such as live preview and auto-save features.

Strict Mode and Deprecated APIs

Strict Mode warns about:

  • Legacy lifecycle methods
  • Unsafe patterns
  • Future-breaking APIs

These warnings prepare your code for future React releases.

Strict Mode vs Production Behavior

Aspect Strict Mode (Dev) Production
Double renderingYesNo
Effect re-runYesNo
WarningsYesNo

Common Misconceptions About React Strict Mode

  • ❌ Strict Mode makes React slower
  • ❌ Strict Mode runs in production
  • ❌ Double rendering is a bug
  • ❌ Strict Mode should be removed

When You SHOULD Use React Strict Mode

  • During development
  • When building new features
  • When upgrading React versions
  • When preparing for concurrent rendering

Strict Mode is strongly recommended for long-term maintainability.

When You Might Limit Strict Mode Usage

  • Legacy codebases with many unsafe patterns
  • Third-party libraries that misbehave

In such cases, Strict Mode can be applied selectively.

Real-World Production Scenario

A dashboard application:

  • Fetches data on mount
  • Subscribes to WebSockets
  • Tracks user interactions

Without Strict Mode:

  • Memory leaks go unnoticed
  • Duplicate subscriptions occur

With Strict Mode:

  • Leaks are exposed immediately
  • Cleanup logic is enforced

These patterns are frequently discussed in advanced React architecture articles.

Best Practices & Special Notes

  • Never disable Strict Mode to silence bugs
  • Fix the root cause instead
  • Write pure render functions
  • Always clean up effects

Testing Strict Mode behaviors through scenario-based questions helps developers fully understand React’s safety mechanisms.

Final Takeaway

React Strict Mode is a powerful safety net designed to help developers write resilient, future-proof React applications. Its intentionally aggressive behavior in development exposes bugs that would otherwise surface in production. Understanding why Strict Mode double-invokes renders and effects is essential for mastering modern React and building high-quality, scalable frontend systems.