☆
8
useEffect runs twice in development, is this a bug?
React 18 StrictMode makes my fetch effect run twice in dev. In production it runs once. I added a cleanup but the request still shows twice in the network tab.
Sphere
React 18 StrictMode makes my fetch effect run twice in dev. In production it runs once. I added a cleanup but the request still shows twice in the network tab.
StrictMode mounts, unmounts, and remounts components to expose missing cleanup. The first request is real; your cleanup must abort it.
3 replies