Reputation: 243
I have the following two buttons:
<View style={styles.button}>
<Button title="ADD" onPress={createDocumentHandler}/>
</View>
<View style={styles.button}>
<Button title="CANCEL" color="red" onPress={props.onCancel}/>
</View>
I want the first button to trigger both the "createDocumentHandler" function and the "props.onCancel" function
I thought it would be as easy as onPress={createDocumentHandler, props.onCancel}
but that only triggers the second method for some reason
Upvotes: 0
Views: 1272
Reputation: 51
Try this
onCancel() => {
{...}
};
function createDocumentHandler()
{
{...}
return onCancel();
}
function render(){
return(
<Button title="ADD" onPress={createDocumentHandler}/>
)
}
Upvotes: 0
Reputation: 12210
You create a custome function createDocumentHandler as :
createDocumentHandler = async() => {
// execute in whatever order
let a = await function1();
let b = await function2();
}
Upvotes: 1
Reputation: 16277
<Button title="ADD" onPress={createDocumentHandler}/>
createDocumentHandler = () => {
actionA();
actionB();
}
Upvotes: 2