negomi / react-burger-menu

:hamburger: An off-canvas sidebar component with a collection of effects and styles using CSS transitions and SVG path animations
http://negomi.github.io/react-burger-menu/
MIT License
5.05k stars 586 forks source link

Close menu if active? #336

Closed alexanderfountain closed 5 years ago

alexanderfountain commented 5 years ago

Wondering if there is a way to close the menu if the user clicks on the active menu item?

negomi commented 5 years ago

Hi @alexanderfountain, you would have to make the menu into a controlled component using the isOpen prop. An example of how to do that is here: https://github.com/negomi/react-burger-menu/wiki/FAQ#i-want-to-control-the-open-state-programmatically-but-i-dont-understand-how-to-use-the-isopen-prop