I have this NavLink exist in a React component where a conditioanl class load if button clicked. Like here,
<NavLink to='property' className={` ${({isActive}) => isActive ? "property-info-nav-active" : "property-info-nav-link"} property-info-nav-item `}>Property</NavLink>
I want to add a additional class to this without button interaction, but I found no way!
I tried this, but it is not working.
<NavLink to='property' className={`${({ isActive }) => (isActive ? "property-info-nav-active" : "property-info-nav-link")} additional-class`}>property</NavLink>
2
Answers
isActive should be state.
You can use the custom function instead of the arrow function.
or you can use
Immediately Invoked Function Expression
: