Navigation 跳转报错
-
按照 官方文档写的 Navigation 跳转的方法为什么,跳转时报错?如下:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Button
} from 'react-native';import { StackNavigator } from 'react-navigation';
// import { ChatScreen } from 'ChatScreen';class HomeScreen extends React.Component {
constructor(props){
super(props);}
static navigationOptions = { title: 'Welcome', } render() { const { navigate } = this.props.navigation; return ( <View> <Text>Hello, Chat App!</Text> <Button onPress={() => navigate('Chat')} title="Chat with Lucy" /> </View> ); }
}
class ChatScreen extends React.Component {
static navigationOptions = {
title: 'Chat with Lucy',
};
render() {
return (
<View>
<Text>Chat with Lucy</Text>
</View>
);
}
}const WOHaoLe = StackNavigator({
Home: { screen: HomeScreen },
Chat: { screen: ChatScreen },
});AppRegistry.registerComponent('WOHaoLe', () => WOHaoLe);