Invariant Violation: The navigation prop is missing for this navigator

后端 未结 10 2589
佛祖请我去吃肉
佛祖请我去吃肉 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-12-01 00:03

    I had the code at the bottom

    export default class App extends React.Component {
      render() {
        return (
          <View >
            <SimpleApp style={{ width: Dimensions.get("window").width }} />
          </View>
        );
      }
    }
    

    I simply replaced it with and it worked like a charm. Definitely, it's because updates in react-navigation library:

    const App = createAppContainer(SimpleApp);
    export default App;
    

    Also, I included createAppContainer library into react-navigation at the top as well.

    0 讨论(0)
  • 2020-12-01 00:07

    I wasted my 2.5 hours to got this solution after many google searches...Hope this will work.

    just import this two:

    import { createStackNavigator } from "react-navigation-stack";
    import { createAppContainer } from "react-navigation";
    

    and make a little change to your code like this:

    create const above the class

    const AppNavigator = createAppContainer(RootStack);
    

    and finally call that const in the class instead of <RootStack/>

    <AppNavigator />
    

    Thankx!

    0 讨论(0)
  • 2020-12-01 00:10

    @Tom Dickson something like this:

    import React, { Component } from 'react';
    import { createStackNavigator, createAppContainer } from 'react-navigation';
    
    import ScreenOne from './ScreenOne';
    import ScreenTwo from './ScreenTwo';
    
    const NavStack = createStackNavigator({
        ScreenOne: { 
            screen: ScreenOne,
        },
        ScreenTwo: { 
            screen: ScreenTwo,
        },
    });
    
    const App = createAppContainer(NavStack);
    
    export default App;
    

    Then reference it with

    <App />
    
    0 讨论(0)
  • 2020-12-01 00:11

    import React, { Component } from 'react';
    import { createStackNavigator, createAppContainer } from 'react-navigation';
    import Home from './home';
    import Details from './details';
    
    const Root = createStackNavigator({
    
        home: { 
    
            screen: Home,
        },
    
        details: { 
    
            screen: Details,
        },
    
    });
    
    const container = createAppContainer(Root);
    export default container;   

    in your App.js file reference it with </container>

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