Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off React StrictMode in React Router v7

If you create a fresh React Router v7 project using a command like:

npx create-react-router@latest <some-project-name>

It looks like React's Strict Mode is enabled by default. Is there a way to turn it off? I can't find any guidance from the docs.

Here's a CodeSandbox and a screenshot to better explain what I mean:

enter image description here

The specific version of the react-router NPM package is 7.1.1 if that helps.

like image 372
Sajad Torkamani Avatar asked Oct 19 '25 02:10

Sajad Torkamani


1 Answers

You should read https://reactrouter.com/explanation/special-files#entryclienttsx

The entry.client.tsx file is optional and it handles the hydration of your app in the client. Its default implementation uses StrictMode.

You can create such a file yourself, or you can run

npx react-router reveal to create the .client and .server files.

Then, you can edit the .client one and remove the <StrictMode> part from it (if you feel you need to).

like image 166
Gabriele Petrioli Avatar answered Oct 21 '25 14:10

Gabriele Petrioli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!