Skip to content

[Bug]: useMatch does not decode params #11777

Closed
@moek

Description

@moek

What version of React Router are you using?

6.23.0

Steps to Reproduce

You can try it here: https://stackblitz.com/edit/github-mfpcog-zdd21p?file=src%2FApp.tsx

Or use this code:

export default function App() {
  return (
    <div>
      <Routes>
        <Route path="/user/:username" element={<Username />}></Route>
      </Routes>
    </div>
  );
}

const Username = () => {
  const params = useParams();
  const match = useMatch('/user/:username');
  return (
    <div>
      hello {params.username} vs {match?.params.username}
    </div>
  );
};

Expected Behavior

I would expect useMatch to decode params the same as useParams does.

If I call this URL /user/bücherwurm of the example above, I would expect the following output:

hello bücherwurm vs bücherwurm

Actual Behavior

It looks like useMatch does no more decode the URL Params.

The example above will output

hello bücherwurm vs b%C3%BCcherwurm

If you use 6.22.0 it works as expected, params are decoded by useMatch

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions