인프런 커뮤니티 질문&답변

김진호님의 프로필 이미지

작성한 질문수

[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스

React State 실습

Server Error Error: The default export is not a React Component in page: "/02-02-counter-state"

해결된 질문

23.02.03 00:57 작성

·

1.1K

0

 강의 들을때마다 점점 지치네요.. 맥 윈도우 다쓰는데 매번 오류나고 뭐가문제인지 모르겠네요 공부를 하려고 해도 의욕이 떨어져요

 

Server Error

Error: The default export is not a React Component in page: "/02-02-counter-state"

This error happened while generating the page. Any console logs will be displayed in the terminal window.

Call Stack

Object.renderToHTML

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/render.js (234:19)

doRender

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/next-server.js (1392:57)

<unknown>

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/next-server.js (1487:34)

<unknown>

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/response-cache.js (63:42)

ResponseCache.get

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/response-cache.js (80:11)

DevServer.renderToResponseWithComponents

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/next-server.js (1423:53)

DevServer.renderToResponse

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/next-server.js (1559:39)

process.processTicksAndRejections

node:internal/process/task_queues (95:5)

async DevServer.pipe

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/next-server.js (1111:25)

async Object.fn

file:///Users/jinho/Desktop/codecamp-frontend-jinho/class/node_modules/next/dist/server/next-server.js (912:21)

답변 1

0

김진호님의 프로필 이미지
김진호
질문자

2023. 02. 03. 01:07

해결한게 export default function Counterstatepage(){} 여기에서 count 스펠링이 틀렸는데

함수선언을 할때 무조건 폴더명이랑 일치해야하나요?

-부분은 제외하고 page는 추가하고

안녕하세요 진호님!

해당 에러는 컴포넌트를 export 할 때 default로 내보내지 않았을 때 발생하는 오류 입니다.
컴포넌트를 그냥 export 만해서 내보내진 않았는지 확인해보시고, 다시 답글 주세요!

그리고 컴포넌트 네임이 반드시 폴더명과 일치해야하는 것은 아닙니다!

- 에러 핸들링 팁 : [ Error: ---에러 메세지--- ] 를 복사해 구글링을 하시면 에러핸들링이 가능함과 동시에 실력도 향상됩니다!

감사합니다.😁

김진호님의 프로필 이미지
김진호
질문자

2023. 02. 04. 21:40

제가 구글에 검색엄청 많이해요 항상 문제있을때마다 하는데도 잘안나오는경우가 많네요 영어를 못하는것도 아니라 stack overflow에서 있는것도 읽어봐도 default빼먹엇냐 하는데 전혀안빼먹고 폴더명하고 컴포넌트이름하고 같게하니까 바로되더라고요 이상하네요