1

反応ネイティブ プロジェクトで NavigatorIOS をテストしています。問題は、ボタンを押してコンポーネントから別のコンポーネントにナビゲートするときです。問題はありませんが、NavigatorIOS が生成したタイトル バーのボタンで戻ろうとすると、「サポートされていない最上位イベント "topScroll"」というエラーが表示されます。発送しました」。

私は react-native-cli = 2.0.1 と react-native = 0.56.0 を使用します

注: サポート コンポーネントで [戻る] ボタンを押すと、すべて問題ありません。

ここに私のコードがあります:

アプリ コンポーネント:

import React, { Component } from "react";
import { View, NavigatorIOS } from "react-native";

import { NavigationApp } from "./src/components/index.js";

export default class App extends Component {
  render() {
    return (
      <NavigatorIOS
        style={{ flex: 1 }}
        initialRoute={{
          title: "Navigation app",
          component: NavigationApp
        }}
      />
    );
  }
}

NavigationApp コンポーネント:

import React, { Component } from "react";
import { Text, View, Button, NavigatorIOS } from "react-native";
import { Support } from "./index.js";

class NavigationApp extends Component {
  navigateToSupport = () => {
    this.props.navigator.push({
      title: "Support",
      component: Support
    });
  };

  render() {
    const { containerStyle } = styles;
    return (
      <View style={containerStyle}>
        <Button
          title="Go to support page"
          onPress={this.navigateToSupport}
        />
      </View>
    );
  }
}

const styles = {
  containerStyle: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center"
  }
};

export { NavigationApp };

サポート コンポーネント:

import React, { Component } from "react";
import { View, Text, Button } from "react-native";

class Support extends Component {
  backAction = () => {
    this.props.navigator.pop();
  };

  render() {
    return (
      <View style={{ flex: 1, justifyContent: "center", alignItems:"center" }}>
        <Text>You are in support page</Text>
        <Button title="Go back" onPress={this.backAction} />
      </View>
    );
  }
}

export { Support };
4

1 に答える 1