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

262
Views
How to redirect page without nesting the url in react-router-dom

I use react-router-dom v5 for routing in my application. In some case I have route like this:

checkup/step-1/:id
checkup/step-2/:id
checkup/step-3/:id

For example, I'm at checkup/step-1/:id so I want to redirect from there to checkup/step-2/:id. To redirect I use hisory.push(). But the result is become like this:

checkup/step-1/:id/checkup/step-2/:id

But my expected result is:

checkup/step-2/:id
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Use / at the start.
For Example:

history.push('/checkup/step-2/:id')

instead of

history.push('checkup/step-2/:id')
about 4 years ago · Santiago Trujillo Report

0

you can use Redirect component provided by react-router-dom

eg:

import {Redirect} from 'react-router-dom'
function MyComponent (){
  return (
    <>
      {condition && <Redirect to='/your-desire-path'/>}
      <MyOtherStaff/>
    </>
  )
}
about 4 years ago · Santiago Trujillo 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!