Hello Friends 👋,
Welcome To Infinitbility! ❤️
This tutorial will help you to call two or multiple functions in react native when user press button or touchableOpecity.
Here, i will share two ways to call multiple functions on onPress, use whatever you like.
Let start today tutorial How to call multiple functions onPress in react native?
Create Common function
In this way, Create new function and call both or multiple functions from there.
functionOne(){
// do something
}
functionTwo(){
// do something
}
functionCombined() {
this.functionOne();
this.functionTwo();
}
<TouchableHighlight onPress={() => this.functionCombined()}/>
Call multiple functions inline
In this way, you can mantion all function in one line in onPress like below example.
functionOne(){
// do something
}
functionTwo(){
// do someting
}
<TouchableHighlight
onPress={
() => { this.functionOne(); this.functionTwo(); }
}
/>
Thanks for reading…