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

95
Views
BrowserRouter as a component creates lots of Router context errors

I have put BrowserRouter into a component called Router and for some reason when I use it that way all sorts of errors relating to functions may only be used in the context of a <Router> component appear. I was just wondering why this happens?

For example:

This works:

<BrowserRouter>
    <Routes>
        <Route path="*" element={<PageNotFound />} />
        <Route path="/" element={<HomeView />} />
    </Routes>
</BrowserRouter>

This doesn't:

// Router Component
const Router = (props) => {

    // Return component
    return (
        <BrowserRouter>
            {props.children}
        </BrowserRouter>
    );

};

// Export
export default Router;
<Router>
    <Routes>
        <Route path="*" element={<PageNotFound />} />
        <Route path="/" element={<HomeView />} />
    </Routes>
</Router>
about 4 years ago · Juan Pablo Isaza
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!