Reaction strict mode

What is React StrictMode and how to use it

you can use itReact.StrictModeBuilt-in components to enable React to execute and warn you of a series of checks.

A simple 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 the application:

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 practice, potential problem and deprecation check.

It does not solve all problems, but you can do a lot of good checks here that can help you solve difficult-to-achieve goals.

It was introduced in React 16.3 in March 2018 and has no impact on production, so you can always keep the component in the code base. When used in development, it will print useful warnings in the browser JavaScript console.

Download mine for freeResponse Handbook


More response tutorials: