I have a form that I used material ui and formik to implement it. Inside, I need to have a selection box, with nested options, it should look like this eventually. (Then I should get the value selected and submit form ) 
For simplicity: I only want recursive children items rendering from a json file:
I have a json file that is nested with children objects. Sample:
[
{
"label": "Bavullar ve \u00c7antalar",
"value": 5181.0,
"children": [
{
"label": "Al\u0131\u015fveri\u015f \u00c7antalar\u0131",
"value": 5608.0
},
{
"label": "Bavul Aksesuarlar\u0131",
"value": 110.0,
"children": [
{
"label": "Korumal\u0131 Kap D\u00fczenleyicileri ve B\u00f6lme Ekleri",
"value": 503014.0
},
{
"label": "Seyahat Keseleri",
"value": 5650.0
},
{
"label": "Seyahat \u015ei\u015fe ve Kaplar\u0131",
"value": 6919.0
}
]
},
{
"label": "Bebek Bezi \u00c7antalar\u0131",
"value": 549.0
},
{
"label": "Bel \u00c7antalar\u0131",
"value": 104.0
},
{
"label": "Elbise \u00c7antalar\u0131",
"value": 105.0
}
...
This is the form I need to insert my dropdown.
// import categories from json file
import categories from '../gpc.tr.json'
// Form component
<form onSubmit={formik.handleSubmit} className={classes.root} id='form'>
<FormhelperText> <span style={{color:'red'}}>*</span> Set Google Product Category ID to </FormhelperText>
<Select id="category" label="Set Google Product Category ID to" fullWidth variant="outlined" name="schema.category"
value={formik.values.schema.category}
onChange={formik.handleChange}
error={formik.touched?.schema?.category && Boolean(formik.errors.category)}
helpertext={formik.touched?.schema?.category && formik.errors.category}>
// HERE I TRY TO INSERT A COMPONENT FOR DROPDOWN
{renderCategories(categories)}
</Select>
so in renderCategories component, I use recursion to render nested children. But I couldn't make it work.
const renderCategories = (categories) => {
return (<div>
{categories.map(i => {
return <MenuItem key={i.value} value={i.value}>
{ i.label }
{ i.children && renderCategories(i.children) }
</MenuItem>
})}
</div>
)}
I get <li> cannot appear as a descendant of <li>. warning and all of the children elements appear all at once. Like in the picture. Even if I style it and hide children elements, I feel like there is a problem here, it gets really slow to render it. How should I solve this problem? Is there a better way to implement it?

Here is the sandbox link: https://codesandbox.io/s/empty-moon-4diw4?file=/src/ProductForm.js
UPDATE
I used NestedMenuItem from "material-ui-nested-menu-item" package. But still, my recursive function doesn't work right.
function renderCategories (categories) {
return categories.map((i) => {
return(
<NestedMenuItem key={i.value} value={i.value}
label={i.label}
parentMenuOpen={!!menuPosition}
onClick={handleItemClick}>
<MenuItem
component={'div'}
onClick={handleItemClick}
key={i.value}> { i.label }
</MenuItem>
{ i.children && renderCategories(i.children) }
</NestedMenuItem>
)
})
}
I get lost here, it doesn't render it properly. how would you implement a recursive dropdown list inside a form in react?
