0

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>
2
  • you want to pass parameters to handleClick? Commented Sep 18, 2021 at 0:11
  • yes please...... Commented Sep 18, 2021 at 0:12

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.