我已经遵循了文档以及stackoverflow的解决方案,但我仍然不断收到错误消息。 这是我的代码。我在做什么错了?
import React, { Component } from 'react';
import { Button, View, Text, StyleSheet } from 'react-native';
import { createStackNavigator,createAppContainer } from 'react-navigation';
import MainScreen from './components/MainScreen';
export default class App extends React.Component {
render() {
return <AppStackNavigator />;
}
}
const AppStackNavigator = createStackNavigator({
Main: {
screen: MainScreen,
},
});
export const Apps = createAppContainer(AppStackNavigator)
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
答案 0 :(得分:1)
您几乎是正确的,只需在根组件中使用Apps:
const AppStackNavigator = createStackNavigator({
Main: {
screen: MainScreen,
},
});
const Apps = createAppContainer(AppStackNavigator)
export default class App extends React.Component {
render() {
return <Apps />;
}
}