DEV Community

Discussion on: Create a Modern Dynamic Sidebar Menu in React Using Recursion

Collapse
 
edenjamal profile image
Jamal Eden

Great article thanks. But what about the button that open and close sub items? Or sub items will be appear by default?

Collapse
 
woeps profile image
Christoph Wanasek

You could extend the SidebarItem component with a prop show: bool = true value, which toggles the rendering.
Then you just wire up the onClick of the "parent ListItem" to toggle the prop of it's "child ListItem".

Collapse
 
edenjamal profile image
Jamal Eden

Thanks a lot.