I have a created checkbox to each of MenuItem in a MUI Menu. And a user can select more than one menu item at a time.
Is there a way to get the selected menu item values ?
Because if I put event.target.value it is giving me on in my alert statement.
https://stackblitz.com/edit/react-avdghj?file=Demo.js
Kindly guide me on how to achieve this.
Any help is much appreciated
Thanks
2
Answers
You can create a state that keeps track of the selected menu items and update it whenever a menu item is clicked.
I also added a
useEffect
to log selected items whenever they changeTry with Mui Autocomplete. You can add a checkbox in menu items and it will return the array of values in the value of handleChange.