支付成功如何跳转到其他页面

How to navigate to another page if payment is success

当我将这行代码放在 onpress() 下方时,代码正常工作

但内部成功回调不起作用

检查处理成功

<TouchableOpacity 
        style={styles.item}
            onPress={() => {
          RazorpayCheckout.open({
            ...
            theme: { color: "#f7b500" }
          })
            .then(data => {
              ***// handle success***
                console.log(`Success: ${data.razorpay_payment_id}`);
                console.log(reference)
                **reference.navigation.navigate("ThankyouScreen", {
                    AvailablePoints: creditScorePoints - item.cash
                });**
            })
            .catch(error => {
             ...
            });
        }}
      >

什么是参考?如果是 this.props 那么确保它是全局定义的。 尝试更改您的代码:

//on top of class
var reference = null;

//In componentDidMount

reference = this.props;