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.
This is my code:
<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)}}>
Just create a function that does both things. No other way around it (if a lib has a utillity for that it would do something similar) since onPress
is a single function.
<Button onPress={() => {
Actions.ideaOnClick()
this.setState({views: ++this.state.views})
}}>