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.
My React components render twice and drive me crazy
Many frontend developers who use modern React, have been pulling their hair out from time to time trying to figure out…
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
Cheers! Now you can sleep well.
Stay safe y’all!