react-native-material-dropdown icon indicating copy to clipboard operation
react-native-material-dropdown copied to clipboard

How i can set dynamic data on dropdown

Open kishanverma26 opened this issue 5 years ago • 4 comments

We can use this array let data = [{ value: 'English', }, { value: 'Hindi', }, ];

and i want to decode this array on drop down

let data = [{ id:'6' name: 'English', }, { id:'7' name: 'Hindi', }, ];

Please help if someone know how i can set dynamic data on drop-down

kishanverma26 avatar Apr 11 '19 10:04 kishanverma26

kishanverma26 you can't do that. You need 'value' key in your data object otherwise data will not show in dropdown. I mean you can't use other key's in your object like 'id' and 'name' except 'value' key.

saadsaleem187 avatar Apr 12 '19 13:04 saadsaleem187

Then this dropdown is useless

sam17896 avatar Jun 29 '19 06:06 sam17896

please use : valueExtractor ={({id})=>id} // this one extract the value from your data labelExtractor ={({name})=>name} //this one extracts the label note "id" and "name" depends on ur data model i just used kish' example model

didolehbal avatar Jul 09 '19 20:07 didolehbal

how to implement if there is no key as 'value' in Data array object, please provide an example OR how to use value/labelExtractor to display Dropdown items?

ajinkyadesai-git avatar Dec 24 '19 14:12 ajinkyadesai-git