What Is React Strict Mode?
React Strict Mode is a tool for highlighting potential problems in an application.
It does not render any visible UI, but it activates additional checks and warnings for development mode only.
Using 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>
);
Key Features
- Identifies unsafe lifecycle methods
- Detects legacy string ref usage
- Warns about deprecated findDOMNode usage
- Helps detect unexpected side effects
Example: Wrapping Components
function Child() {
return <h2>Hello Strict Mode</h2>;
}
function App() {
return (
<React.StrictMode>
<Child />
</React.StrictMode>
);
}
✅ React will double-invoke some functions in development to check for side effects.
Conclusion
React Strict Mode is a development tool that helps catch potential issues early and ensures your app is future-proof.
Citations
https://savanka.com/category/learn/react/
https://www.w3schools.com/REACT/DEFAULT.ASP