[Solved] React Issue: Selected Style Not Working

Source code:

<NavLink to="/home1" activeClassName="selected"> Home Page 1</NavLink>
        <NavLink activeStyle={{
            fontWeight: 'bold',
            color: 'red'}}
          to="/home2"> Home Page 2

report errors:

index.js:1 Warning: React does not recognize the `activeClassName` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `activeclassname` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

First check your version:

All versions above V6 will report this error. Just change back to V5. At the same time, if you use <Routes> Please delete this V6 attribute

Similar Posts: