Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to Pass multiple functions to onClick button in material UI

I have a button that looks like:

<Grid item xs={4} sm={12} md={6}>
                    <Button
                      variant="contained"
                      color="success"
                      type="submit"
                      onClick={(handleClick, handleSubmit)}
                      value="Send"
                    >
                      Send message
                    </Button>
                    <Snackbar
                      open={open}
                      autoHideDuration={5000}
                      onClose={handleClose}
                    >
                      <Alert
                        variant="filled"
                        severity="success"
                        autoHideDuration={500}
                        onClose={handleClose}
                      >
                        {"Message sent!"}
                      </Alert>
                    </Snackbar>
                  </Grid>

The button only calls the first function passed to onClick send button. How do make it so that both functions are called?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

const onSendMsg = () => {
  handleClick()
  handleSubmit()
}

Then change to onClick={onSendMsg}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading