Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda