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

244
Views
React router order of routes, does it matter?

I set up my react router like this:

<Route exact path="/users">
    <component/>
</Route>
<Route exact path="/users/:id">
    <component/>
</Route>

And it wasn't working correctly (url was changing but content wasn't) after I changed the order of Route in my Routes.js (the one with :id first) it started working. Do it matters or there is other problem somewhere in my code?

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

0

Yes you need to check

Route and Switch

<Switch> is unique in that it renders a route exclusively. In contrast, every <Route> that matches the location renders inclusively.

Read and explore more at https://reactrouter.com/web/api/Switch

about 4 years ago · Juan Pablo Isaza Report

0

Yes, nested routes should be above its parent.

So in the following code, about/user has to be above /about. If its beneath then only /about will render

<Route path='about/user' />
<Router path='about/' />
about 4 years ago · Juan Pablo Isaza Report

0

Basic React Router Setup

    <Router>
        <Switch>
          <Route path="/about">
            <About />
          </Route>
          <Route path="/users">
            <Users />
          </Route>
          <Route path="/">
            <Home />
          </Route>
        </Switch>
    </Router>
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!