Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

181
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda