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

Link instead of "a" leaves menu open on item select #307

Closed ceich closed 5 years ago

ceich commented 5 years ago

When my menu items are React Router Link components, the menu stays open after I click on the link.

When my menu items use <a>, the menu closes as expected.

I am using version 2.6.4 so I don't think the 1.x FAQ item applies.

negomi commented 5 years ago

Hi @ceich,

That's probably because your page is refreshing when you use <a> tags, but not with React Router links.

To use the menu with React Router, you'll want to control the menu open state manually, so you can tell it to close when a link is clicked. See here for how to do that: 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

ceich commented 5 years ago

Thanks, I saw that but didn't make the connection. Will proceed as indicated.