๊ฐœ๋ฐœ ๐Ÿพ/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,
}

 

๋ฐ˜์‘ํ˜•