To pass event with parameter with React onClick, we set the onclick
prop to a function that calls another function.
For instance, we write
const clickMe = (event, someParameter) => {
//...
};
//...
<button
onClick={(e) => {
clickMe(e, someParameter);
}}
>
Click Me!
</button>
to create the clickMe
function.
Then we set the button’s onClick
prop to a function that calls clickMe
with the e
event object and someParameter
.