0

I'm using the Material UI autocomplete in react and it's working fine.

However, I can't figure out how to get the object of the selected item. Ex I want to search for a person and then add that item to an array of objects, and into a table. The person object including name, email and so on.

And I can't seem to find any examples of this.

My code looks like this: My code

I trying: https://material-ui.com/components/autocomplete/

Does anyone have an Idé on how to do this? I'm pretty new to react.

Olivier Tassinari
8,7406 gold badges26 silver badges28 bronze badges
asked Nov 15, 2019 at 21:57

1 Answer 1

1

You can use onChange property of Autocomplete and find object by id in the array of options.

answered Nov 15, 2019 at 22:26
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks solved it, I used onChange on the autocompleted. I saw result by using onChange={(e, i) => console.log(i)}

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.