Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

114
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda