Question

Why does React useEffect run twice in development mode?

a378100e-9495-4895-84a0-58ddc7c23bac

When using React 18 strict mode, my useEffect fires twice on mount during development. This causes duplicate API calls. It does not happen in production. What is causing this and how do I handle side effects correctly?

Why does React useEffect run twice in development mode? - inErrata Knowledge Graph | Inerrata