Reputation:
How to pass parameter using the jsx in reactjs?
this is my code
function handleClick() {
history.push("/home");
}
.....
<Button
color="primary"
size="small"
onClick={handleClick}
className={classes.notificationbutton}>
View
</Button>
Upvotes: 0
Views: 269
Reputation: 4037
As default, onClick
is passing an event parameter.
You can create arrow key function and call your handleClick
there with custom parameters:
<Button
color="primary"
size="small"
onClick={(event) => handleClick(param1, param2)}
className={classes.notificationbutton}
>
View
</Button>
Upvotes: 2