ReactJS - Why console.log executed two times?

Hello there.

For future posts, it would be much more useful if you posted some code, or a link to your project on CodePen, jsFiddle, or similar.

This was also discussed somewhat here: Simple React Component Renders twice when using the useState hook

I suspect it is an issue with the way most online editors render. That being said, if you are hosting locally, and rendering using something like create-react-app, then I am not sure why your component would be rendered twice.

1 Like