I have a problem in combine 2 action in the same button
<Button
disabled={!isFormValid}`
onClicked={this.submitHandler}
/>
I want to add this function with the previous one
() => this.popUpHandler('update');
The first action to submit form and next to close popup after that. Do you have any idea about it?
Use Anonymous_functions .
<Button
disabled={!isFormValid}
onClicked={ () => {
this.popupHandler("Update");
console.log('Button clicked');
}}
/>
Or create a separate handler;
Class Something extends React.Component {
onButtonClick() {
// Do anything
this.popupHandler("Update");
console.log('Button clicked');
}
render() {
return (
<Button
disabled={!isFormValid}
onClicked={this.onButtonClick()}
/>
);
}
}
You can simply use
submitHandler(){
//after some condition you can call here another function
this.popUpHandler('update')
}
popUpHandler(var){
//your logic
}
<Button
disabled={!isFormValid}
onClicked={this.submitHandler}
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.