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!

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chindalath Traymany

Chindalath Traymany

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

More from Medium

Transitioning from Plain JS to React.

React, Redux, and Rails

How To Accept Payments On Your Website Via A Stripe Integration(with a React front-end and Ruby…

React Native: How to Fix Watchman Operation Not Permitted Error