-3

I created this minimal React snippet and when reloading it, I get:

enter image description here

I'm not even using props, state or any other hooks, why would React need to call it twice?

    function Component() {
      console.log("running Component()", Math.random());
      return <>Hello</>;
    }

    export default function App() {
      return (
        <div className="App">
          <Component />
        </div>
      );
    }

CodeSandbox

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Petruza
  • 11,744
  • 25
  • 84
  • 136
  • 3
    Have you read e.g. https://stackoverflow.com/q/48846289/3001761? Virtually any search for "react render twice" will get you to: strict mode. – jonrsharpe Aug 27 '23 at 17:56

0 Answers0