왜 export default를 변수 선언과 같이 사용 할 수 없는가?

김장남·2024년 1월 28일
1

토끼굴

목록 보기
1/1

export default function AComponent() {
  ...
}

는 되는데

export default const AComponent = () => {
  ...
}

는 안되는가?! 에서 출발했습니다.

빠른 결론

관련 StackOverflow 질문, export 관련 ECMAScript
default문 뒤에는 HoistableDeclaration, ClassDeclaration, AssignmentExpression
만 사용 할 수 있습니다.

  • HoistableDeclaration: function, function *
  • ClassDeclaration: class
  • AssignmentExpression: 표현식, 값으로 평가될수 있는 것(?)

근데 const, letLexicalDeclaration이기 때문에 사용 할 수 없습니다.

profile
React 개발자

0개의 댓글