Invariant Violation: The navigation prop is missing for this navigator

后端 未结 10 2604
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 23:20

I am receiving this message when I tried starting my react native app. Usually this kind of format works on other multi screen navigation yet somehow does not work in this c

10条回答
  •  执念已碎
    2020-11-30 23:46

    Create a new file ScreenContainer.js (you can choose the name). Then in the ScreenContainer file add:

    import React, { Component } from 'react';
    import { createStackNavigator, createAppContainer } from 'react-navigation';
    import MainScreen from './MainScreen'; 
    import AboutScreen from './AboutScreen';
    
    const NavigationStack = createStackNavigator({
        Main: { 
            screen: MainScreen,
        },
        About: { 
            screen: AboutScreen,
        },
    });
    
    const Container = createAppContainer(NavigationStack);
    
    export default Container; 
    

    Then at your App.js file:

    import Container from './ScreenContainer';
    
    class App extends Component {
      render() {
        return (
          
        );
      }
    }
    

提交回复
热议问题