Framework/Next.js

[Next.js] Error: The default export is not a React Component in page: "/" ์˜ค๋ฅ˜

yuri lee 2022. 11. 8. 20:51
๋ฐ˜์‘ํ˜•

Intro

next js ๋ฅผ ์‚ฌ์šฉํ•˜๋˜ ๋„์ค‘ ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค. 

 

Error: The default export is not a React Component in page: "/"

Why?

์—๋Ÿฌ๊ฐ€ ๋‚œ ์ฝ”๋“œ๋ฅผ ํ™•์ธํ•ด๋ณด๋‹ˆ, export ๋งŒ ํ•˜๊ณ  default ๋ฅผ ์ ์–ด์ฃผ์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. Next.js์—์„œ๋Š” default๋กœ export๋ฅผ ํ•ด์•ผ ์—๋Ÿฌ ์—†์ด ์ •์ƒ ์ž‘๋™ ๋˜๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

export function HomePAge() {
  const featuredEvents = getFeaturedEvents();
  return (
    <div>
      <EventList items={featuredEvents} />
    </div>
  );
}

 

How to solve the problem

export default ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๐Ÿ™Œ

export default function HomePAge() {
  const featuredEvents = getFeaturedEvents();
  return (
    <div>
      <EventList items={featuredEvents} />
    </div>
  );
}

 

๋ฐ˜์‘ํ˜•