RoundedButton не влияет на приложение iOS / Android - PullRequest
0 голосов
/ 28 апреля 2019

Я использую React Native Navigation 2.18.2. Я изменяю обратный вызов RoundedButton onPress, но, похоже, мои изменения не вступают в силу на обеих платформах. Я хочу нажать новый экран при нажатии кнопки.

Я разрабатываю свой проект на основе предоставленной игровой площадки разработчиками.

OptionsScreen.js (частично):

class Options extends Component {
  static options() {
    return {
      topBar: {
        visible: true,
        testID: TOP_BAR,
        title: {
          text: "Styling Options"
        },
        rightButtons: [
          {
            id: "ROUND",
            testID: ROUND_BUTTON,
            component: {
              name: Screens.RoundButton,
              passProps: {
                title: "Two"
              }
            }
          }
        ]
      }
    };
  }
  ...
}

RoundedButton.js

const { Navigation } = require("react-native-navigation");
const Screens = require("./Screens");

class RoundedButton extends Component {
  constructor(props) {
    super(props);
    this.subscription = Navigation.events().bindComponent(this);
    this.state = {};
  }

  handleButtonPress = () => {
    Alert.alert(this.props.title, "Thanks for that :)");
    Navigation.push(this.props.componentId, {
      component: {
        name: Screens.Pushed
      }
    });
  };

  render() {
    return (
      <View style={styles.container}>
        <View style={styles.button}>
          <TouchableOpacity onPress={this.props.onClick}>
            <Text style={styles.text}>{this.props.title}</Text>
          </TouchableOpacity>
        </View>
      </View>
    );
  }
}

module.exports = RoundedButton;

При нажатии на кнопку появляется предупреждение, но оно не переходит на нужную страницу.

...