• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

React Navigation 셋업 오류

21.09.20 23:55 작성 조회수 817

0

routes.js 작성하고 AuthStack.Navigator로 화면 호출할때 오류나는거 저만 그런가요...?

 

Couldn't find a 'component', 'getComponent' or 'children' prop for the screen 'main'. this can happen if you passed 'undefined' you likely forgot to export your component from the file it's defined in, or mixed up default import and named import when importing

 

찾아보니까 import 시킬때

import { 이름 } from './compont';

-> 

import  이름 from './compont';

이렇게 변경하라는 답변들이 많았는데 전 이미 그렇게 했는데도 오류가 뜨는데 다른 요인이 있을수 있을까요...

해당 import 하는 클래스 파일에도 하단에 export 한 상태입니다...

답변 1

답변을 작성해보세요.

0

김부릉님, 안녕하세요.

import를 할 때 중괄호 사용 여부는, 다른 파일에서 export하는 방법에 따라 상이합니다.

default로 export를 하게 되면 import할 때 중괄호를 안 쓰고요,

그렇지 않은 경우에는 import할 때 중괄호를 쓰게 됩니다.

e.g.
case1) export하는 파일에서 -> export class example extends Component { ...}
               import하는 파일에서 -> import { example } from '[export하는파일경로]'
case2) export하는 파일에서 -> export default class example extends Component { ...}
               import하는 파일에서 -> import example from '[export하는파일경로]'

 

routes.js 작성하고 AuthStack.Navigator로 화면 호출할때 오류 라고 하는게 정확히 어떤 부분인지요? 

강의에서는 'compont' 라는 경로를 사용하지 않는데, 혹시 경로나 파일 이름을 부분적으로 임의 생성하신거라면, import시 문제가 될 수 있습니다.

감사합니다.