How to close react-burger-menu when link click in a component?
See original GitHub issuei want to close my sidebar menu when a link is click not outside or cross button click just link click then my sidebar menu automatically close itself. But problem is my link is under another component , Suppose my component <ShipForMe/>
and my link is under <ShipForMe/>
like <NavLink to="/dashboard/ship-for-me/my-request/pending">My Request</NavLink>
Sidebar.js
<div className="sidebar-wrap " id="outer-container">
<div className="dashboard-menu rounded">
<ShipForMe/>
<MyWallet/>
<Profiles/>
<div className="sidebar-item ds-item">
<div className="sidebar-item__title">
<NavLink to="">VIP Center</NavLink>
</div>
</div>
</div>
<div className="dashboard-responsive rounded">
<Menu pageWrapId={ "page-wrap" } outerContainerId={ "outer-container" } isOpen={false}>
<div id="page-wrap" style={{marginTop: '-25%'}}>
<ShipForMe handleUrl={handleUrl}/>
<MyWallet/>
<Profiles/>
<div className="sidebar-item ds-item">
<div className="sidebar-item__title">
<NavLink to="">VIP Center</NavLink>
</div>
</div>
</div>
</Menu>
</div>
</div>
ShipForMe.js
<div className="ship-wrap ds-item">
<div className="sidebar-item">
<div className="sidebar-item__title">
Ship for me
</div>
<ul className="sidebar-item__lists">
<li>
<NavLink to="/dashboard/ship-for-me/my-request/pending">My Request</NavLink>
</li>
<li>
<NavLink to="/dashboard/ship-for-me/forwarding-parcel/abroad-to-bd">My Forwarding Parcel</NavLink>
</li>
</ul>
</div>
</div>
Note: isOpen{flase}
is not working, it is only working when link is physical there.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to close react-burger-menu when link click in a ...
In your Menu component, add: (1) onOpen={handleOpen} , (2) onClose={handleOpen} , and (3) isOpen={isOpen} properties.
Read more >Closing a navigation menu in React - DEV Community
This is surprisingly easy. I have a mobile nav, which has a hamburger icon to open it. Once it's open that icon changes...
Read more >react-burger-menu examples - CodeSandbox
Learn how to use react-burger-menu by viewing and forking react-burger-menu example apps on CodeSandbox.
Read more >React Menu component - Material UI - MUI
When close to a screen edge, a basic menu vertically realigns to make sure that all menu items are completely visible. Choosing an...
Read more >How to create a multilevel dropdown menu in React
Closing the dropdown menu when users click outside it ... we will replace it with the Link or NavLink component from the react-router-dom...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, they both demonstrate the same concepts, so you can use whichever you like.
can i use 2nd example (react hooks) for my problem