[TIL] useEffect 에서 2번씩 호출될때

LUCY·2023년 1월 11일
0

TIL

목록 보기
1/3
post-thumbnail

next.js 를 사용하고 있는데 useEffect가 두번씩 호출이 되는 문제가 있었다.

  useEffect(() => {
      console.log("bbbddd")
  }, [])

React.StrictMode 가 설정되어 있을 경우 그렇다.

react

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

next

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false,  // true -> false 변경
};

module.exports = nextConfig;

0개의 댓글