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
314 stars 134 forks source link

React Native TypeError: undefined is not an object (evaluating 'props.getItem') #139

Closed web-2017 closed 1 year ago

web-2017 commented 1 year ago

Simulator Screenshot - iPhone 14 Pro Max - 2023-05-26 at 13 45 26

const [selected, setSelected] = useState([ { key: 1, value: 'PieChart' }, { key: 2, value: 'Table' }, ])

<SelectDropdown data={selected} 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 return selectedItem }} 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 return item }} />

AdelRedaa97 commented 1 year ago

You are passing an array of objects, to render a title for the button after selection use return selectedItem.value and for each row use return item.value