์ฝ”๋”ฉ ๋ฉ”๋ชจ

[error] next 13 : Uncaught Error: invariant expected app router to be mounted

Dong _ hwa 2023. 7. 22. 03:15

 

next.js 13 ๋ฒ„์ „์—์„œ layout.tsx๋ฅผ ์ˆ˜์ •ํ•จ๊ณผ ๋™์‹œ์— ์˜ค๋ฅ˜๊ฐ€ ๋‚ฌ๋‹ค.

 Uncaught Error: invariant expected app router to be mounted  at useRouter
 app-index.js:32 The above error occurred in the <HotReload> component:

์—๋Ÿฌ๊ฐ€ ๋‚˜๋ฉด chat GPT ํ•œํ…Œ ๋จผ์ € ๋ฌผ์–ด๋ณด๋Š”๋ฐ, next.13๋ฒ„์ „์€ ๋”ฑํžˆ ์ด์šฉํ•˜๊ธฐ๊ฐ€ ์• ๋งคํ•˜๋‹ค.. ใ… ,ใ… 

์ฑ— ์ง€ํ”ผํ‹ฐ์˜ ๋งˆ์ง€๋ง‰์ด 2021๋…„ 9์›”์ธ๊ฐ€ ๊ทธ๋ž˜์„œ.. ๊ทผ๋ฐ 13๋ฒ„์ „์€ ๋‚˜์˜จ์ง€ ์–ผ๋งˆ ์•ˆ๋ผ์„œ ์ฑ—์ง€ํ”ผํ‹ฐ๊ฐ€ ๋˜‘๊ฐ™์€ ๋Œ€๋‹ต๋งŒ ๋ฐ˜๋ณตํ•œ๋‹ค ์‹ถ์œผ๋ฉด ์•„ ์ด๊ฑฐ next ๋ฌธ์ œ๊ตฌ๋‚˜ํ•˜๊ณ  ๋ฐ”๋กœ ๊ตฌ๊ธ€๋กœ ๋…ธ์„ ์„ ํ‹€์–ด๋ฒ„๋ฆฌ๋ฉด ๋จ..

 

https://github.com/vercel/next.js/issues/42829

 

Next 13 - dev environment React is not enabled / client components don't update · Issue #42829 · vercel/next.js

Verify canary release I verified that the issue exists in the latest Next.js canary release Provide environment information Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Ver...

github.com

 

layout.tsx
export default function RootLayout({children}: {
  children: React.ReactNode;
}) {
  return (
    <>
      <AnimalHeader />
      <section
        className="pt-12"
        style={{ height: "100vh", width: "100%", paddingLeft: "12%" }}
      >
        {children}
      </section>
    </>
  );
}

๊ธฐ์กด์— ๋‚ด๊ฐ€ ์ž‘์„ฑํ•œ ๋ฐฉ์‹๊ณผ ๊ฐ™์•˜๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ <html>, <body> ํƒœ๊ทธ๊ฐ€ ์—†์—ˆ๋˜ ๊ฒƒ...

 

๋ณ€๊ฒฝํ•œ ์ฝ”๋“œ
export default function RootLayout({children}: {
  children: React.ReactNode;
}) {
  return (
    <>
      <html lang="ko">
        <body>
          <AnimalHeader />
          <section
            className="pt-16"
            style={{ height: "100vh", width: "100%", paddingLeft: "12%" }}
          >
            {children}
          </section>
        </body>
      </html>
    </>
  );
}

 

 

 

๋ฃจํŠธ ๋ ˆ์ด์•„์›ƒ์€ html ๋ฐ body ํƒœ๊ทธ๋ฅผ ํฌํ•จํ•ด์•ผ ํ•จ!