React 18 Strict Mode gọi useEffect 2 lần trong development để detect side effects.
Fix:
- Đây là behavior đúng, production chỉ gọi 1 lần.
- Dùng cleanup function abort previous request.
- Hoặc dùng React Query/SWR thay vì fetch trực tiếp trong useEffect
React 18 Strict Mode intentionally calls useEffect twice in development to help detect side effects.
Fixes:
- This is the correct behavior — production only calls it once.
- Add a cleanup function to abort the previous request.
- Or use React Query/SWR instead of fetching directly in useEffect