I've got that object :
foodDatas: {
"_id": "603cf063c9f3a13528634bab",
"description": "petit déjeuner parisien local sur l'ile",
"hotel": "603cd6ae5206ad4f04296218",
"nameArticle": "Parisien",
"prix": 15,
"type": "PetitDejeuner",
"detail": [
{ "pastries": ["croissant","pain au chocolat"] },
{ "drinks": ["café","thé"] },
{ "fromages": ["kiri", "camembert"] },
],
}
What I want to do is to map through detail array to display each element of the value of the objects that contains each of its elements.
In others terms, I want to make a list like below
pastries:
- croissant
- pain au chocolat
drinks:
- café
- thé
fromages:
- kiri
- camemebert
I've tried this :
{Object.keys(foodDatas.detail).map((category, i) => {
return (
<>
<Text style={styles.category}>{category}</Text>
// From here I want to map through category to display its content**
<View style={styles.choices}>
<View style={styles.options}>
<TextInput
style={styles.input}
onChangeText={handleChange("croissant")}
placeholder={"1"}
keyboardType={'numeric'}
value={values.croissant}
/>
<Text style={styles.itemOption}>Croissant</Text>
</View>
</View>
</>
)
})}
But I didn't get the name of the categories (pastries, fromages, etc.), instead I've got their index (0,1, etc.). Also, I don't know how to retrieve the value of each category ( croissant, pain au chocolat, café, etc.)
Thank for any help you can give
{type:'pastries, items:["croissant","pain au chocolat"]}rather than using unique key names generated by the category names