How to fix function being called twice in React?

To fix function being called twice in React, we disable strict mode.

For instance, if we have

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

then we disable strict mode by removing the React.StrictMode component from the code.