React Components Rendering Twice in Development
This drove me nuts! I could not for the life of me figure out why my components were rendering twice. Marios however summed it up pretty well.
He talks about why it renders twice, and the main reason is that React.StrictMode
is trying to help you debug.
Rest assured, this only happens in development and doesn’t happen in production. Still, this bug drove me nuts for a while because I could not for the life of me figure out why everything was rendering twice!!! A real hair-puller for sure.
I highly recommend giving his blog a quick read because it definitely helped me understand why my components were rendering twice in development. rest assured though, this is not a bug and is intended for debugging purposes with React.StrictMode
.
Cheers! Now you can sleep well.
Stay safe y’all!