我只是按照示例https://reactnavigation.org/docs/en/hello-react-navigation.html中的说明将react-navigation库迁移到3.0中,最后出现以下错误。不确定这个错误是什么意思?
错误
App.js
import React from "react";
import { View, Text } from "react-native";
import { createStackNavigator, createAppContainer } from "react-navigation";
import HomeScreen from './screens/Home';
const AppNavigator = createStackNavigator({
HomeScreen: {
screen: HomeScreen
}
});
const AppContainer = createAppContainer(AppNavigator);
export default class App extends React.Component {
render() {
return <AppContainer/>;
}
}
主屏幕:
import React, { Component } from 'react';
import {
Text,
View
} from 'react-native';
export default class HomeScreen extends Component {
render() {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Text>Home Screen</Text>
</View>
);
}
}
修改1: 如果我直接在App.js中渲染主屏幕,那么主屏幕就很好了。
我是打电话
export default HomeScreen;
代替此
export default class App extends React.Component {
render() {
return <AppContainer/>;
}
}