In DropDownPicker I am trying to add map dynamically which's failing in syntax. Need help with the syntax as it looks logically correct to me. I was able to find loop example for Picker but not for DropDownPicker
<View>
<DropDownPicker
items={[
mealItems.map((option) =>(
{
label: {option.name}, // Getting error here
value:{option.id},
icon: () => (
<View style={styles.arrowAdd}>
<FoodPlus />
</View>
),
}, //Getting error here to remove the comma but that's required
)
)
]
}
//Dropdown attributes such as style etc
/>
</View>
My response data that I am trying to loop looks like following:
[{"id": 1, "name": "Breakfast"}, {"id": 2, "name": "Morning Snack"}, {"id": 3, "name": "Lunch"}, {"id": 4, "name": "Evening Snack"}, {"id": 5, "name": "Dinner"}]