I want to get all properties of a particular input option. For an example lets think my options list is
const options = [
{ id: 1, state: 'AL' },
{ id: 2, state: 'AK' },
{ id: 3, state: 'AZ' },
{ id: 4, state: 'AR' },
{ id: 5, state: 'CA' }
]
<AsyncTypeahead
ref={textBoxRef}
options={options}
/>
By using ref I can access input node of typehead as ref.current.getInput()
. Ans also I can take the selected value by using ref.current.getInput().value
.
But how can I take the id attribute in the options list. So if there is any functionality take all the attributes of a particular selected options please mention it.
I solved this problem by using onChange prop. It has mentioned in the documentation.
Link: enter link description here
I can access all the attributes of a selected option by using selected parameter in the onChange prop
onChange={(selected)=>{
console.log(selected)
}}