createStackNavigation invariant violation element type is invalid expected a string

后端 未结 2 972
谎友^
谎友^ 2021-01-27 21:13

Upon creating importing and using createStackNavigation I\'m getting the following error. Any help would be greatly appreciated! Also, this is my first app in react-native so pl

相关标签:
2条回答
  • Its the problem with 'export default' and import with {} or without {}.

    Change this line

    import { MainNavigation } from '../screens/MainNavigator';
    

    to (remove the curly brackets)

    import  MainNavigation  from '../screens/MainNavigator';
    
    0 讨论(0)
  • 2021-01-27 21:43

    On the DLLoading_2 page

    const AppContainer = createAppContainer(MainNavigation);
    
    • It's okay if you don't have the above code.
     constructor(props) {
        super(props);
    
        this.state = {};
      }
      .
      .
      .
    this.props.navigation.navigate('DlMain')
    
    
     <View style={styles.root}>
            <Center />
    
    • Is this necessary?

      MainNavigator.js

    const AppContainer = createAppContainer(MainNavigator);
    
    export default AppContainer;
    
    0 讨论(0)
提交回复
热议问题