Simply, how can I disable Strict Mode in React 18? I'm using React 18 with create-react-app.
Asked
Active
Viewed 1.7k times
2 Answers
15
Look for this code in index.js and remove the outer element:
<React.StrictMode>
<App />
</React.StrictMode>
Note:
Strict mode checks are run in development mode only; they do not impact the production build.

isherwood
- 58,414
- 16
- 114
- 157
-
5If this tag `
` wasn't in my index.js file, then this means that strict mode is not enabled? I don't have these in my index.js file but my very simple code is executing twice – Dec 29 '22 at 14:46 -
[Why is my function being called twice in React?](https://stackoverflow.com/questions/50819162/why-is-my-function-being-called-twice-in-react) – isherwood Dec 29 '22 at 14:46
-
Sounds like you asked an [XY question](http://xyproblem.info). – isherwood Dec 29 '22 at 14:47
-
I don't have this piece of code :( – samuelnehool Aug 07 '23 at 18:59
-
1Then you're not in strict mode, @samuelnihoul. – isherwood Aug 07 '23 at 19:04
-
But I have an issue caused by double rendering that I did not have before React 18 and that only occurs in dev mode. What gives? – samuelnehool Aug 07 '23 at 19:07
-
That sounds like a different question and should be presented as such, not here. Please take the [tour]. – isherwood Aug 07 '23 at 19:15
0
To disable strict mode in React 18, you need to look-up for the below-given code in index.js.
<React.StrictMode>
<App />
</React.StrictMode>
Now Remove the outer element and your code will look like this:
<App/>
This will disable strict mode.

Shashank saxena
- 31
- 3