개발 🐾/Error

nextjs _app.js useEffect에서 두번 호출 하는 문제

JOTOKKI 2023. 11. 29. 16:39
728x90

 

 

 

 

참고: https://dev.to/jahid6597/why-useeffect-is-running-twice-in-react-18c6

 

React18 버전이후 StrictMode일때 useEffect 가 두번씩 호출된다고 한다. 

한 번만 호출하고 싶다면, next.config.js 에서 strictMode를 끌 수 있다. 

 

// next.config.js

const nextConfig = {
  reactStrictMode: false,
}

 

반응형