反应原生导航不起作用

时间:2018-04-24 05:14:52

标签: react-native react-native-navigation

导航时,正在运行从第一个屏幕切换到第二个屏幕。但是我无法从第二个屏幕切换到第三个屏幕。我想从第二个屏幕切换到第三个屏幕。我不知道我犯了哪些错误。我分享下面的代码。你能帮助我吗。 ?谢谢

尊重

import React, { Component } from 'react';
import {
  WebView,
  AppRegistry, StyleSheet, Text, View, Button
} from 'react-native';

import { StackNavigator } from 'react-navigation';




 class App extends Component {

  static navigationOptions =
  {
     title: 'App',
  };

  OpenSecondActivityFunction = () =>
  {
     this.props.navigation.navigate('Second');

  }

  render() {
    return (
      <View style={styles.container}>

       <Button onPress = { this.OpenSecondActivityFunction } title = 'Open Second Activity'/>
      </View>
    );
  }
}



 class SecondActivity extends Component
{
  static navigationOptions =
  {
     title: 'SecondActivity',
  };

     OpenThirdActivityFunction = () =>
  {
     this.props.navigation.navigate('Third');

  }

  render()
  {
     return(


            <View style={{  flex: 1}}>

             <Button onPress = { this.ThirdActivityFunction } title = 'Open Third Activity'/>

        </View>

     );
  }
}

 class ThirdActivity extends Component
{
  static navigationOptions =
  {
     title: 'ThirdSecondActivity',
  };

  render()
  {
     return(


            <View style={{  flex: 1}}>

             <Text>3</Text>

        </View>

     );
  }
}


export default ActivityProject = StackNavigator(
{
  First: { screen: App },

  Second: { screen: SecondActivity },

  Third: { screen: ThirdActivity }
});

const styles = StyleSheet.create({


  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },ActivityNameTextCss:
  {
     fontSize: 22,
     color: 'black',
     textAlign: 'center',
  },

});

AppRegistry.registerComponent('ActivityProject', () => ActivityProject);

1 个答案:

答案 0 :(得分:0)

SecondActivity课程中,您在this.ThirdActivityFunction时调用OpenThirdActivityFunction方法。将OpenThirdActivityFunction的名称更改为ThirdActivityFunction