【发布时间】:2019-04-22 02:59:24
【问题描述】:
我是本机反应的新手,我正在尝试创建一个带有堆栈导航的应用程序。这就是我的 App.js 上的内容
import React from "react";
import { View, Text } from "react-native";
// Import React Navigation
import { createStackNavigator, createAppContainer } from 'react-navigation'
// Import the screens
import Main from './components/Main';
import Chat from './components/Chat';
// Create the navigator
const navigator = createStackNavigator({
Main: { screen: Main },
Chat: { screen: Chat },
});
const App = createAppContainer(navigator)
export default navigator
这也是我遇到的错误
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
This error is located at:
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at registerRootComponent.js:17)
in RootErrorBoundary (at registerRootComponent.js:16)
in ExpoRootComponent (at renderApplication.js:34)
in RCTView (at View.js:44)
in RCTView (at View.js:44)
in AppContainer (at renderApplication.js:33)
- node_modules/@react-navigation/core/src/navigators/createNavigator.js:19:8 in getDerivedStateFromProps
- node_modules/react-native/Libraries/Renderer/oss/ReactNativeRenderer-dev.js:7663:46 in applyDerivedStateFromProps
- ... 20 more stack frames from framework internals
我明显做错了,请帮忙
【问题讨论】:
-
您是否阅读了该链接上的信息?这可能是 stackoverflow.com/q/53367195/1531971 的副本
-
@Siraj 谢谢我把它修好了。我不得不导出“App”并纠正了一个
错误。谢谢大家
标签: reactjs react-native react-navigation