AdelRedaa97 / react-native-select-dropdown

react-native-select-dropdown is a highly customized dropdown | select | picker | menu for react native that works for andriod and iOS platforms.
MIT License
320 stars 137 forks source link

data never accepts objects array #84

Closed DonRyu closed 2 years ago

DonRyu commented 2 years ago
<SelectDropdown
                  data={[{item: 'asd', value: 'asd'}, {item: 'asd', value: 'asd'}]}
                  onSelect={(selectedItem, index) => {
                    console.log(selectedItem, index)
                  }}
                  buttonTextAfterSelection={(selectedItem, index) => {
                    // text represented after item is selected
                    // if data array is an array of objects then return
                    // selectedItem.property to render after item is selected
                    console.log('selectedItem', selectedItem)
                    return selectedItem.value
                  }}
                  rowTextForSelection={(item, index) => {
                    // text represented for each item in dropdown
                    // if data array is an array of objects then return item.property to represent item in dropdown
                    console.log('item', item.value)

                    return item
                  }}
                />

Show error Document said I can use objects array to data but there is no mention which the form of object (What kind of key I should use?)

AdelRedaa97 commented 2 years ago

It accepts an array of objects, try to use examples in the example folder, and which version do you use?

Nziranziza commented 1 year ago

It accepts an array of objects, try to use examples in the example folder, and which version do you use?

Let's say I have an array of object where one of the property is id, would it be possible to have the property id as the main thing to consider while choosing the value. At the moment it has to consider all the properties of the item in the list