React Strict Mode

Photo by Dim Hou on Unsplash

React’s StrictMode is a sort of helper component that helps us write less bug-prone code. It does not render visible UI, but runs checks on its descendents in development mode.

To usee StrictMode, simply wrap your code in the component. In the example below, I’ve called StrictMode in my index.js file.

import React from 'react';import ReactDOM from 'react-dom';import Wrapper from './components/Wrapper';ReactDOM.render(    <React.StrictMode>        <Wrapper />    </React.StrictMode>,    document.getElementById('root'));

Now, my console will warn me if a component is not following some of the recommended practices, if I am using deprecated methods, or of any other potential risks.

StrictMode is particularly useful in wrapping suspicious code blocks while debugging. The next time you are debugging in React, try it out!

--

--

Chindalath Traymany

Laotian-American woman pursuing my passion for mentally stimulating and complex problem-solving through programming.