What is the right way to define data structure of category and subcategory ? #225
-
Hi,
Now i have to make menu component that renders the category along with subcategory and i have two question.
array of objects containing array values ? const menu = [
mealType: ["breakfast", "Lunch", "Snack", "teatime"],
cuisineType: [
"merican",
"asian",
"british",
"caribbean",
"central europe",
"chinese",
"eastern europe",
"french",
],
dishType: ["side dish", "soup", "starter", "sweets"],
] or objects of objects containing array values const menu = {
mealType: ["breakfast", "Lunch", "Snack", "teatime"],
cuisineType: [
"merican",
"asian",
"british",
"caribbean",
"central europe",
"chinese",
"eastern europe",
"french",
],
dishType: ["side dish", "soup", "starter", "sweets"],
}
const Menu = [
mealType: ["breakfast", "Lunch", "Snack", "teatime", { icon: <GiMeal /> }],
cuisineType: [
"merican",
"asian",
"british",
"caribbean",
"central europe",
"chinese",
"eastern europe",
"french",
{ icon: <SiCodechef /> },
],
dishType: ["side dish", "soup", "starter", "sweets", { icon: <BiDish /> }],
] I'm more concerned about the second question |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @Deepak8717 I didn't get completely about the categories and subcategories there. Are you saying, the user will first select a For the second question of having the icon(component reference) as part of the data, I do not see that as an issue. |
Beta Was this translation helpful? Give feedback.
-
@atapas , No they are all independent. anyway i have achieved this but i wasn't able to store component it keeps giving me errors. If you could point out some resource on how to store component especially icons as some icons do give this freedom like material but not all. this time i did this with help of ternary operator as there were only three icons. |
Beta Was this translation helpful? Give feedback.
@atapas , No they are all independent. anyway i have achieved this but i wasn't able to store component it keeps giving me errors. If you could point out some resource on how to store component especially icons as some icons do give this freedom like material but not all. this time i did this with help of ternary operator as there were only three icons.