【问题标题】:Invariant Violation: The navigation prop is missing for this navigator. in react-navigation 4不变违规:此导航器缺少导航道具。在反应导航 4
【发布时间】:2020-05-29 09:25:02
【问题描述】:

我正在尝试为我的 React 本机应用程序创建一个导航抽屉,使用 2 个屏幕、主屏幕和连接屏幕,但我不断收到此错误:

Invariant Violation: The navigation prop is missing for this navigator. In 
react-navigation 3 you must set up your app container directly. More info: 
https://reactnavigation.org/docs/en/app-containers.html

请问我的代码有什么问题。 我的 App.js:

import React from 'react';
import Search from './Components/Search'
import { createDrawerNavigator } from 'react-navigation-drawer'
import { createStackNavigator,createAppContainer } from 'react-navigation'
//import  Connection from './Screens/ConnectionScreen';
import  AccueilScreen from './Screens/AccueilScreen';

export default class App extends React.Component {
  render(){
    return (
      <AppDrawerNavigator/>
        );
  }

}

const AppDrawerNavigator = createDrawerNavigator({
  //Se_Connecter: Connection,
  Accueil:{ 
    screen : AccueilScreen,
  },
});
const AppNavigator= createAppContainer(AppDrawerNavigator);

【问题讨论】:

标签: javascript android reactjs react-native expo


【解决方案1】:

您正在渲染 DrawerNavigator 而不使用 AppContainer(您创建的)

export default class App extends React.Component {
  render(){
    return (
      <AppNavigator/>
    );
  }
}

【讨论】:

  • 非常感谢我没有注意那个细节。问题不再存在
猜你喜欢
  • 2019-04-22
  • 2019-04-21
  • 1970-01-01
  • 2019-08-27
  • 1970-01-01
  • 2021-08-29
  • 2019-09-11
  • 2019-12-08
  • 1970-01-01
相关资源
最近更新 更多