cyntler / hamburger-react

Animated hamburger menu icons for React.js weighs only 1.5 KB.
https://hamburger-react.netlify.app
MIT License
963 stars 36 forks source link

Close menu when Link to is clicked. #43

Closed benjaminthedev closed 3 years ago

benjaminthedev commented 3 years ago

Hi folks,

This is a great library so thank you! I have a question when a user toggles open the menu and clicks a Link to - is that a way to have the menu close again. Here is my code:

Screenshot 2021-08-09 at 13 24 52

I have tried to use:

toggled={isOpen} toggle={setOpen}

On the menu anchor tag and list item tag too. What am I doing wrong here?

Thank you,

Ben.

luukdv commented 3 years ago

Hi! 👋

Thanks. You can do the following:

<Link onClick={() => setOpen(false)} to="/">Home</Link>