How to insert 2 functions into onClick event ReactJS?

<Button onClick={submitHandler}>

I have this button which already has an assigned function to its onClick event. I also want to add <Button onClick={() => Toggle()}> this Toggle function into same button. How can I do it?

>Solution :

Simply create a function which calls both of the functions. Assuming submitHandler needs the event object, that will look like:

<Button onClick={(event) => {
  submitHandler(event);
  Toggle();
})}>

Leave a Reply