Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
React Router V6 full stop making URL invalid

Using useRoutes and Outlet. I have the following route example:

const routes = [
  {
    path: "/",
    element: <Dashboard/>,
    children: [
      { path: "/*", element: <Profile /> },
      { path: "/*/example", element: <Example/> },
    ],
  }
]

const App= () => {
  const route = useRoutes(routes)
  return <div>{route}</div>
}

I want to push user_id to the url so for example /user1 this loads the component as expected however when I type something like /firstname.surname I get the follow error Cannot GET /firstname.surname however /firstname.surname/example does load the component

This is due to the full stop in the Id. How can I resolve this and accept it as a valid URL?

When I update path for dashboard to "" it seems to work however when I do something like /foo.bar/test it loads profile component how do I restrict this as this path does not exists?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I think the wildcard in { path: "/*/example", element: <Example/> } doesn't work well with other routes also specifying the wildcard. It's my understanding that the "/*" is valid only at the end of the path to indicate matching more deeply nested routes.

The following config seems to work though, using a named path param.

const routes = [
  {
    path: "/",
    element: <Dashboard />,
    children: [
      { path: "/*", element: <Profile /> },
      { path: "/:path/example", element: <Example /> }
    ]
  }
];

Edit react-router-v6-full-stop-making-url-invalid

about 4 years ago · Juan Pablo Isaza Report

0

const routes = [
  {
    path: "/",
    element: <Dashboard/>,
    children: [
      { path: "/:id", element: <Profile /> },
      { path: "/:id/example", element: <Example/> },
    ],
  }
]

const App= () => {
  const route = useRoutes(routes)
  return <div>{route}</div>
}

"*" is a generic wildcard need to pass id like above

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!