Home > Mobile >  How to get specific object key in array using MUI multiple autocomplete and useState hook?
How to get specific object key in array using MUI multiple autocomplete and useState hook?

Time:03-23

I want to get id key in the given array list. When the user selected any object in a given array list need to get the id value to the state. How can I do it?

This is the sandbox link: https://codesandbox.io/s/tags-material-demo-forked-ffuvg4?file=/demo.js

CodePudding user response:

If you just want to set the ids to the state your can use map

onChange={(event, newValue) => {
          setValue(newValue.map((v) => v.id));
        }}
  • Related