Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda