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

82
Vistas
React pass information to child of Route

I am building a react navigation and have to pass info to the sidenav. Therefore I have to pass props to my body, but the body is rendered by a router and I can't just pass them. I have seen a lot on this, but always with self-closing tags, so that you can just paste the props in the render function of the Route. Below the code:

App.js

function App() {
//...
return (
<Router>

  <Switch>
    {Object.keys(routesGroupedByLayouts).map(layoutName => {
      const LayoutTag = layouts[layoutName];
      const layoutRoutes = routesGroupedByLayouts[layoutName].map(route => route.path);

      return <Route key={`layout-${layoutName}`} exact={true} path={layoutRoutes} render={() => {
        return (
          <ScrollToTop>
            <LayoutTag>
              <h1>sdsdddscxcxs</h1>
              <Switch>
                {routesGroupedByLayouts[layoutName].map(route => (
                  <Route key={route.path}
                         path={route.path}
                         exact={route.exact === true}
                         render={() => <route.component fallback={<Loading />} />} />
                ))}
              </Switch>
            </LayoutTag>
          </ScrollToTop>
        )
      }} />
    })}
  </Switch>
</Router>
);
}

default.jsx

const Default = ({children}) => {
//...
return (
    <Layout>
      <Layout.Body id={"main-content"}>
        <div>
          {children}
        </div>
      </Layout.Body>
    </Layout>
  )
}

I hope I pasted everything needed here. So the LayoutTag passes the children to the default.jsx, but I don't know how to pass the children to the rendered Body of the Route element. I have to pass the body a function that executes in default.

Hope somebody can help me out, thanks in advance!

about 4 years ago · Juan Pablo Isaza
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