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

187
Views
¿Cómo usar slugs de URL dinámicos (id) con React Router Dom?

Estoy tratando de tener un enrutador que se parezca a este home/{id}/{question} . Y hasta ahora pude establecer una identificación dinámica al hacerlo:

 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> ); }

Y úsalo de esta manera para hacer la redirección:

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

Pero, ¿qué tal si también quiero agregar la identificación de la pregunta, para tener algo que se vea así: home/{id}/{question} .

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

0

Puedes configurarlo de esta manera:

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

Puedes hacer una redirección a esa URL así:

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

Y finalmente podría obtenerlos en Home con la ayuda de 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 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!