简体   繁体   中英

What exactly <React.StrictMode></React.StrictMode> component does?

I found this component inside a React practice, but i don't know what's the exact behavior.

eg

const App = () => {
  return (
    <React.StrictMode>
      <div id="cool-attribute">
        <h1>Welcome to the Jungle!</h1>
        <SearchParams />
      </div>
    </React.StrictMode>
  );
};

First you need to understand is What actually a Strict Mode is.

Strict Mode is a mode in which compiler gets extra careful with some additional instructions, does not eliminate silent errors on its own instead throws them out and put more limitations while coding. For more information, please follow

React.StrictMode is a same thing but to provide more limitations while working specifically with React. Here is a comprehensive guide

If you are expecting something in UI, please stop because according to React.StrictMode documentation:

StrictMode does not render any visible UI. It activates additional checks and warnings for its descendants.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM