React Native 0.41:navigator.push不起作用

时间:2017-02-13 19:55:48

标签: android reactjs react-native navigator

Android设备4.4.4,ReactNative 0.41。

class MyScene extends Component {

  render() {
    return (
  <View style={styles.container}>
    <Text>Current Scene: {this.props.title}</Text>
    <TouchableOpacity onPress={this.props.onForward}>
      <Text>Tap me to load the next scene</Text>
    </TouchableOpacity>

    <TouchableOpacity onPress={this.props.onBack}>
      <Text>Tap me to go back</Text>
    </TouchableOpacity>
  </View>
    )
  }
}


class CounterApp extends Component{


  render(){
    return (
      <Navigator
       initialRoute={{ title: 'My Initial Scene', index: 0 }}
       renderScene={(route, navigator) =>
      <MyScene
        title={route.title}

        // Function to call when a new scene should be displayed
        onForward={() => {
          const nextIndex = route.index + 1;
          navigator.push({
            title: 'Scene ' + nextIndex,
            index: nextIndex,
          });
        }}

        // Function to call to go back to the previous scene
        onBack={() => {
          if (route.index > 0) {
            navigator.pop();
          }
        }}
      />
    }
  />
    )
  }

}

所以问题是:我可以使用navigator.replace({...})更改场景,但是当我点击onPress = {() => navigator.push({...})}的按钮并使用相同的数据时,它就会停止工作。没有应用程序的答案,唯一的交互方式是关闭它XD。所有代码均来自Official documentation tutorial

0 个答案:

没有答案