Navigation 跳转报错



  • 按照 官方文档写的 Navigation 跳转的方法为什么,跳转时报错?如下:
    0_1498723369904_Simulator Screen Shot 2017年6月29日 下午4.00.42.png
    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);


登录后回复