-
Notifications
You must be signed in to change notification settings - Fork 583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider adding a prop for close on clicking item #423
Comments
Hi @anasik, Do you mean something like a That sounds reasonable, I'd accept a PR for it. Will leave this open. |
I have FC with state and handler like below
This doesnt work correctly, when clicking to Link it closes only once. Think that is because when I click to Burger Button it doesnt triggering |
Hey @boverU, You have the right idea, but the code above is invalid because you need to pass functions to the Try this: const [isMenuOpen, handleMenu] = useState(true);
const handleCloseMenu = () => {
handleMenu(false);
};
<Menu isOpen={isMenuOpen}>
<CustomLink
onClick={() => {
handleCloseMenu();
history.push('/home');
}}
/>
<CustomLink
onClick={() => {
handleCloseMenu();
history.push('/work');
}}
/>
</Menu> |
@negomi Sorry, since I`m not allowed to make copies of code directly I typed it manually and forgot about calling function paranthesis. Can you check out this one on codesandbox.io, the problem still having the place - https://codesandbox.io/s/frosty-dewdney-zotlj?file=/src/Navbar.js and closes sidemenu only once. Thank you |
Oh I see! Now the issue is that you need to add the I adapted your example to make it work: https://codesandbox.io/s/charming-breeze-u1tck?file=/src/Navbar.js |
Thanks man!) You saved a lot of my time!) |
I know this is possible right now and there's even an example that shows how to do it but it's a ittle inefficient to have to add an onclick to each menu item. It would be cool to have a prop that allows you to enable/disable this.
The text was updated successfully, but these errors were encountered: