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

169
Views
Passing props to Outlet when nesting so I could use componentDidUpdate

Im using react-router-v6 and I have problems with my setup. I'm using nested routing with layouts with following settings.

App.js

<BrowserRouter>
      <Routes>     
        <Route exact path='/' element={<SiteLayout />} />
      </Routes>
      <Routes>
        <Route path='/app/' element={<AppLayout />} >
          <Route path='dashboard' element={<Dashboard />} />
          <Route path='send' element={<Send />} />
        </Route>
      </Routes>
    </BrowserRouter>

AppLayout is a class element and have some state variables and data fetching im passing to Dashboard component through <Outlet /> using context at the moment. This works fine but the Dashboard component should be able to do its own rest call using data passed from AppLayout when new data arrives. This I was planning to do with componentDidUpdate in Dashboard component but what i understood it does not work with context? So every time I pass context to Dashboard it does not fetch data and does not update. How could i continue from here? Im tearing my hair here atm :D trying to figure how to work with this. Is there some other way to automatically run a function when class component gets new data?

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

0

just do this instead.

<BrowserRouter>
      <Routes>     
        <Route exact path='/' element={<SiteLayout />} />
        <Route path='/app/' element={<AppLayout />} />
        <Route path='/app/dashboard' element={<Dashboard />} />
        <Route path='/app/dashboard/send' element={<Send />} />
      </Routes>
</BrowserRouter>
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!