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

127
Views
React Router with Context

I'm wrapping some private routes with a context, but for some reason it doesn't move to the next route in the switch.

export const Routes = () => (
  <Switch>
    <Route exact path="/" component={Home} />
    <Route path="/seller/:userName" component={userProfile} />
    <Route path="/allproducts" component={AllProducts} />
    <Route path="/privacy" component={Privacy} />
    <Route path="/terms" component={Terms} />
    <Route path="/contact" component={Contact} />
    <Route path="/about" component={About} />
    <Route path="/learnmore" component={LearnMore} />
    <Route path="/faq" component={FAQ} />
    <PublicRoute path="/login" component={Login} />
    <PublicRoute path="/signup" component={SignUp} />
    <PublicRoute path="/reset" component={ForgotPassword} />
    <PublicRoute path="/resetToken" component={ForgotPasswordToken} />
    <PrivateRoute exact path="/userprofile" component={UserDashboard} />
    <PrivateRoute exact path="/submitplate" />

// This works but doesn't allow the router to move to the next potential route.

    <BasketProvider>
      <PrivateRoute exact path="/checkout" component={Checkout} />
    </BasketProvider>

// This never gets reached. 

    <Route component={NoMatchPage} />

  </Switch>
);


Just wondering if theres a better way to go around this? Is this bad practice?

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

0

Does it work if you do this?

 <PrivateRoute exact path="/checkout" component={() => (
   <BasketProvider>
     <Checkout />
   </BasketProvider>
 )} />
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!