React Native error: Element type is invalid: expected a string or a class/function but got: object

后端 未结 9 778
不知归路
不知归路 2020-12-28 13:39

I am getting this error and I am having a lot of trouble fixing this.

What I am trying to do here is have 3 different screens and have a tabbar that navigates to eac

9条回答
  •  灰色年华
    2020-12-28 14:00

    This is probably caused by some JS module export/import issues in your program, typically for one of the two reasons listed below:

    • You forget to export, or you export something incorrectly
    • You import something that doesn't exist, or you import something incorrectly

    I ran into similar error, but in my case, it is not caused by export but caused by import, and I used the import statement incorrectly to import something that doesn't exist in the module.

    In my case, the import was incorrectly written as:

    import { MyComponent } from './MyComponents/MyComponent'

    while actually it should be:

    import MyComponent from './MyComponents/MyComponent'

    And it drove me crazy and took me a whole day to figure it out and I hope this will save several hours for some people.

提交回复
热议问题