This is the data fetched from WebAPI and stored in a state called items
this.setState({
items: dataSource
staffId: ''
})
This state of items will be this.
[
{"departmentName":"KYAUKSE MAINTENANCE","employeeName":"AUNG THU1", "staffId" : "00001"},
{"departmentName":"KYAUKSE MAINTENANCE","employeeName":"AUNG THU2", "staffId" : "00002"},
{"departmentName":"KYAUKSE MAINTENANCE","employeeName":"AUNG THU3", "staffId" : "00003"}
]
I would like to create a dropdown in react native with just the emplyeeName
let staff = [{
value: 'AUNG THU1',
}, {
value: 'AUNG THU2',
}, {
value: 'AUNG THU3',
}];
<Dropdown
label='Staff Name'
baseColor='#0079b5'
data={staff}
onChangeText={(value) => this.onChangeName(value)}
/>
Edit: Thank you for the answers! I would like to know whether it is possible to get the staffId of the selected value in DropDown? So if i were to select AUNG THU 1, the onChange method would trigger and I would like to set the state of staffId to it.