使用React-Navigation的StackNavigator时出现错误。
下面我向您展示我的代码,我拥有的版本以及package.json的所有配置
这是代码:
import {React} from 'react'
import { StackNavigator } from 'react-navigation';
import LoginForm from '../view/screen/LoginForm'
import Setting from '../view/screen/Setting'
export const AppNavigator = StackNavigator({
Login: { screen: LoginForm },
Setting: { screen: Setting }
});
这是我的配置:
1. react-navigation@1.5.13
2. npm version: 5.6.0
3. react-native-cli: 2.0.1
4. react-native: 0.57.5
这是我的package.json
"dependencies": {
"firebase": "^5.5.9",
"react": "16.6.1",
"react-native": "0.57.5",
"react-native-elements": "^0.19.1",
"react-native-navigation": "^2.2.0",
"react-native-ui-lib": "^3.6.1",
"react-navigation": "^1.0.0-beta.22",
"react-redux": "^5.1.1",
"redux": "^4.0.1",
"redux-thunk": "^2.3.0"
}
该错误显示在屏幕截图中
App.js是。 21行是带有提供程序组件的行。 看:没有添加StackNavigator,我没有错误。
import AppNavigator from "./routers/Router"
render(){
return (
<Provider store={createStore(reducers, {}, applyMiddleware(ReduxThunk))}>
<AppNavigator />
</Provider>
)
}
}
export default App;
答案 0 :(得分:0)
解决方案是使用export const
在AppsNavigator中更改export default
。
export default AppNavigator = StackNavigator({
Login: { screen: LoginForm },
Setting: { screen: Setting }
});