Skip to content

[Bug]: NavLink isn't triggered for routes with params that need uriEncoding #9604

@lifeiscontent

Description

@lifeiscontent

What version of React Router are you using?

6.4.3

Steps to Reproduce

I have a route called:

/profiles/:username

where if someone has a username like Magda Parry the browser properly encodes the URI to /profiles/Magda%20Parry but NavLink doesn't trigger an active state when it should. e.g:

                  <NavLink
                    className={(props) =>
                      clsx("nav-link", {
                        active: props.isActive,
                      })
                    }
                    end
                    to={`/profiles/${username}`}
                  >
                    My Articles
                  </NavLink>

where username here is a param from useParams

Expected Behavior

I'd expect even in cercumstances where a route param needs URI Encoding, NavLink should still trigger its active states.

Actual Behavior

doesn't trigger an active state if there are spaces within the route param.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions