I have a button that looks like:
JavaScript
x
26
26
1
<Grid item xs={4} sm={12} md={6}>
2
<Button
3
variant="contained"
4
color="success"
5
type="submit"
6
onClick={(handleClick, handleSubmit)}
7
value="Send"
8
>
9
Send message
10
</Button>
11
<Snackbar
12
open={open}
13
autoHideDuration={5000}
14
onClose={handleClose}
15
>
16
<Alert
17
variant="filled"
18
severity="success"
19
autoHideDuration={500}
20
onClose={handleClose}
21
>
22
{"Message sent!"}
23
</Alert>
24
</Snackbar>
25
</Grid>
26
The button only calls the first function passed to onClick send button. How do make it so that both functions are called?
Advertisement
Answer
JavaScript
1
5
1
const onSendMsg = () => {
2
handleClick()
3
handleSubmit()
4
}
5
Then change to onClick={onSendMsg}