Skip to content

React StrictMode

New Course Coming Soon:

Get Really Good at Git

What is React StrictMode and how to use it

You can use the React.StrictMode built-in component to enable a set of checks that React performs and warns you about.

An easy way is to wrap the entire App component in <React.StrictMode></React.StrictMode> in the index.js file:

import React from 'react'
import ReactDOM from 'react-dom'

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
document.getElementById('root')

You can also use it by wrapping one or more components of your app:

import React from 'react'

class Hello extends React.Component {
  render() {
    return (
    <div>
      <React.StrictMode>
      ...
      </React.StrictMode>
    <div>
    )
  }
}

One of the main use cases of this component is to be used as an automated best practices, potential problems and deprecations check.

It can’t catch all, but you have lots of nice checks here that can help you fix the low-hanging fruits.

Introduced in React 16.3 in March 2018, it has zero impact in production, so you can always leave the component in the codebase. Used in development it will print useful warnings in the browser JavaScript console.

Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!
→ Get my React Beginner's Handbook
→ Read my full React Tutorial on The Valley of Code

Here is how can I help you: