affinipay / react-bootstrap-autosuggest

A modern combo-box built for React and Bootstrap
https://affinipay.github.io/react-bootstrap-autosuggest/
ISC License
56 stars 18 forks source link

Return object from onChange #19

Closed The-Code-Monkey closed 6 years ago

The-Code-Monkey commented 6 years ago

when i give an array such as [{ id: 1, name: "test"}]

when i select an item i need it to return the object not just the name how do i do this or why isnt this the default way of doing it?

trevorr commented 6 years ago

You need to enable valueIsItem, as shown in the demo.

It's not the default because it generally requires a little extra setup to define how to construct objects for input values that didn't come from the datalist (assuming you're not using datalistOnly). For example, see the documentation for the onChange event regarding how valueIsItem changes its behavior.