【发布时间】:2018-11-20 21:06:29
【问题描述】:
我收到这个错误,这让我发疯了,我什至无法在 React Native 上启动一个简单的应用程序。我正在使用最基本的例子,一个新的项目,仍然抛出这个错误。 我使用 react-navigation v3xx 有人请帮忙,因为我疯了,谢谢。 这是我的代码:
import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View, Button, TouchableHighlight} from 'react-native';
import { createAppContainer, createStackNavigator, StackActions, NavigationActions } from 'react-navigation'; // Version can be specified in package.json
class Home extends React.Component {
static navigationOptions = {
title: "Home",
}
render() {
return (
<View style={styles.container}>
<Text>Home Page</Text>
<Button onPress={() => this.props.navigation.navigate('About')} title="All about me" />
</View>
);
}
}
class AboutMeMe extends React.Component {
static navigationOptions = {
title: "All Me",
}
render() {
return (
<View style={styles.container}>
<Text>Home Page</Text>
<Button onPress={() => this.props.navigation.goBack()} title="<< Back" />
</View>
);
}
}
const AppScreens = createStackNavigator({
Home: Home,
About: AboutMeMe
})
const App = createAppContainer(AppScreens);
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
export default App;
【问题讨论】:
标签: react-native react-native-ios react-native-navigation