MUI Treeview
(v6
) component is not expanding on manual click when using expanded property, not sure why it's not expanding
<TreeView
defaultCollapseIcon={<MinusSquare />}
expanded={nodeIds}
selected={selected}
defaultExpandIcon={<PlusSquare />}
defaultEndIcon={<CloseSquare />}
>
{GetTreeItemsFromData(props.treeItems)}
</TreeView>
Based on the docs of the TreeView API
from the Material-UI, to expand a node, you need to pass in the node IDs as an array into either expanded
or defaultExpanded
.
So if you can't expand a node, perhaps you can try to see if nodeIds
is an array in the state first, then see if you properly trigger a re-render when you update the state. If not, then probably you have not yet set up this state properly.
Reference: TreeView API