DEV Community

Aman Kureshi
Aman Kureshi

Posted on

πŸ” StrictMode in React β€” Catch Problems Before They Happen

React.StrictMode is a development tool that helps identify potential problems in your React app. It does not affect production, only runs in development.

🎯 Why use StrictMode?
β€’ Warns about unsafe lifecycle methods
β€’ Detects unexpected side effects
β€’ Highlights legacy code that may break in future versions
β€’ Helps ensure best practices

πŸ”§ How to enable:

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>
); 
Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Key points:
β€’ Only affects development mode
β€’ May render components twice (to detect side effects)
β€’ No impact on production performance
β€’ Encouraged for new React projects

React.StrictMode is like a safety net β€” it won’t fix your code but will warn you about risky patterns early.

Top comments (0)