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

后端 未结 9 733
不知归路
不知归路 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:16

    Modify your SwitchView to this:

    import Feed from './app/pages/Feed/Feed';
    import Board from './app/pages/Board';
    import Wiki from './app/pages/Wiki';
    export default class SwitchView extends Component {
    render(){
        var { id } = this.props;
    
        switch (id) {
            case "FeedView":
                return <Feed/>
            case "WikiView":
                return <Wiki/>
            case "BoardView":
                return <Board/>
        }
    }
    }
    
    0 讨论(0)
  • 2020-12-28 14:17

    How is that different from module.exports = SwitchView?

    For me module.exports works for all of my js files except one.

    0 讨论(0)
  • 2020-12-28 14:17

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

    1. You forget to export or you export something incorrectly
    2. You import something that doesn't exist or you import something incorrectly

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

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