在React Native中向onPress函数添加多个事件 [英] Adding multiple events to onPress function in React Native

查看:370
本文介绍了在React Native中向onPress函数添加多个事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按下按钮时,它应该导航到另一个页面,这也会增加视图数。

When I press the button, it supposed to navigate to another page and it also increase the view count.

但是我还是想不起来同时实现它们。

But I can't figure out anyway to implement them at the same time.

这是我的代码:

<Button onPress={Actions.ideaOnClick}>
<Button onPress={() => this.setState({views: ++this.state.views})}>


推荐答案

yourFunction(){
 Actions.ideaOnClick();
 this.setState({views: ++this.state.views});
}

<Button onPress={this.yourFunction.bind(this)}}>

这篇关于在React Native中向onPress函数添加多个事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆