#navLink

1 messages · Page 1 of 1 (latest)

bleak jolt
#

i have a problem with using NavLink.
value of "isActive" is never changed even i'am in the right page,
here is my code.

<NavLink
to={/${loginInfo.name}/setting}
style={isActive => ({
color: isActive ? "green" : "blue"
})}

hello
    </NavLink>

please help me😭

subtle creek
#

as far as I remember you need to do ({ isActive })

#

the function receives an object with isActive as a property

#

so the reason it's always true is because an object is a truthy value

bleak jolt
#

Thank you for your answer. But its didnt work. My isActive always comes false

bleak jolt
#

i just fixed it not by using "/" on the "to" value;

#

before : to = "/name/setting"
after : to="setting"