Dynamically add 'active' prop in MDB Bootstrap Rea


Topic: Dynamically add 'active' prop in MDB Bootstrap React Navbar

Raghav Sharma asked 3 months 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/


Piotr Glejzer staff commented 3 months ago

You can change active with a state with conditions.

<MDBNavItem active={yourState? true : false } />


Please insert min. 20 characters.
Status

Open

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: React
  • MDB Version: 4.26.1
  • Device: Macbook
  • Browser: Google Chrome
  • OS: Mac OS Catalina
  • Provided sample code: No
  • Provided link: Yes
Tags