Topic: Dynamically add 'active' prop in MDB Bootstrap React Navbar
Raghav Sharma asked 5 years ago
Expected behavior
How do I add the active class dyanmically i.e send via prop in mdbootstrap react navbar?
I want it to change as soon as I click on a <MDBNavitem>
<MDBNavItem active>
<MDBNavLink to="#!">Home</MDBNavLink>
</MDBNavItem>
Resources (screenshots, code snippets etc.)
https://mdbootstrap.com/docs/react/navigation/navbar/
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Open
- User: Free
- Premium support: No
- Technology: MDB React
- MDB Version: 4.26.1
- Device: Macbook
- Browser: Google Chrome
- OS: Mac OS Catalina
- Provided sample code: No
- Provided link: Yes
Piotr Glejzer staff commented 5 years ago
You can change active with a state with conditions.
<MDBNavItem active={yourState? true : false } />