New in React, looking for a good way to build a set of nested components given a nested props object.
Take the following basic props example:
const props = [{
label: 'Foods',
children: [
{ label: 'Chicken', children: [] },
{ label: 'Pasta', children: [] }
]
}];
I would like to use this to build a nested menu:
<Item>
<Label>Foods</Label>
<Item><Label>Chicken</Label></Item>
<Item><Label>Pasta</Label></Item>
</Item>
While this is a simple example, the nesting would go much deeper.
I have searched around for this, and all I am finding are pre-built components. I'm not looking for magic yet, I'm trying to understand how things work before I use other components.
What is the best way to generate a React component to efficiently render this?