Strict mode runs your Component twice to ensure reusability. By removing React strictMode tag from index.js. this can be solved.

This is intended behavior to help detect unexpected side effects. You can read more about it in the docs. It happens only in development environment, while in production componentDidMount is called only once even with <React.StrictMode>.

From:

<React.StrictMode>
  <App />
</React.StrictMode>

To:

root.render(<App />);

By toihid