React-Native Invariant Violation: Element type is invalid

后端 未结 4 1772
别跟我提以往
别跟我提以往 2021-01-07 18:41

When I going to run my react native app on my iPhone Expo this error displayed in red background area.

Invariant Violation: Element type is invalid: e

相关标签:
4条回答
  • 2021-01-07 18:47

    I had this error from doing my export in the following style with no default export specified. I did not specify a default because I was exporting multiple small components from one file.

    export const  Modal  = (props) => (
        <div className="someClass">
        </div>        
      )
    

    I was able to get it working by adding brackets to the import statement.

    import {Modal} from '../components/Modal.js'
    
    0 讨论(0)
  • 2021-01-07 18:49

    i had same issue and i put export default before class yourclassname extends Component in App.js

    0 讨论(0)
  • 2021-01-07 18:59

    In my case instead of exporting like this:

    export default App;
    

    ...I exported like following:

    export {LoginForm};
    

    It worked completely fine.

    0 讨论(0)
  • 2021-01-07 19:13

    Expo expects you to export a component from /App.js. But right now you are only importing into /App.js. Expo is not receiving any component to render. You need to export the component you imported like this:

    export default App;
    

    On side note: Use a class component only if you must.

    0 讨论(0)
提交回复
热议问题