'How to call more than one function in javascript onclick event? [duplicate]

<Button onClick={(e)=>setId(_id); handleDelete()}>Delete

I tried this way, but it gives error.



Solution 1:[1]

I think you must wrap the content of the arrow function in { }, like this

<Button onClick={(e) => {setId(_id); handleDelete()} }>Delete</Button>

and don't forget the closing tag for the Button component

I hope that solves your problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ht3aa