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

183
Visualizações
How to use dynamic url slugs (id) with React Router Dom?

I'm trying to have a router that looks like this home/{id}/{question}. And so far I was able to set one dynamic id by doing so:

export default function Navigation() {
  return (
    <Routes>
      <Route path="" element={<LoginScreen />} />
      <Route path="/home-screen/:id" element={<Home />}>
      </Route>
      <Route path="/hom" />
      {/* <Route path='./home-screen/leaderboard' element= */}
    </Routes>
  );
}

And use it this way to make redirection:

 nav("home-screen/" + currentSelectUser?.id, {
    state: {
      user: currentSelectUser,
    },
  });

But how about if I want to add the id of the question as well, to have something that looks like this: home/{id}/{question}.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can set it up this way:

<Route path="home/:firstId/:secondId" element={<Home />} />

You can make a redirection to that url like so:

nav("home/" + currentSelectUser?.id + "/" + currentSelectUser?.id, {
    state: {
      user: currentSelectUser,
    },
  });

And finally you could get them in Home with the help of useParams:

import { useParams } from "react-router-dom";
function Home() {
  let { firstId, secondId } = useParams();
  console.log(firstId, secondId);
  return <div className="page">Hello</div>;
}
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