본문으로 바로가기

default export와 named export의 차이

category Coding 8년 전

ES module에서 default, named export의 차이를 쉽게 설명해 놓은 글들을 찾기가 어려웠는데

StackOverflow에 좋은 설명 글이 있어서 가져와 봅니다.


http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281


요약하자면..

default export는 1개만 존재 가능하고, 나머지는 named export.

default export된거는 아무 이름으로 import 가능하지만 named import ( { A } )는 할 수 없고,

named import를 하기 위해서는 named export를 해야만 한다.


예제들이 포함되어 있으니 위의 링크 글을 참고하시는게 좋습니다.