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

223
Vistas
Layout is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>. How should I overcome this error?
<Routes>
        <Route exact path='/'>
          <Layout>
            <Home></Home>
          </Layout>
        </Route>
      </Routes>

Layout consists of header and footer, I want to wrap my home inside Layout.
React 18.1.0
react-router-dom 6.0.2

error

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Other Route components are the only valid children of a Route component. This is the use case of building nested routes. For routed content/components, these must use the element prop.

Render the Layout component as the element of the Route component.

Example:

<Routes>
  <Route
    path='/'
    element={(
      <Layout>
        <Home />
      </Layout>
    )}
  />
</Routes>

It also common to have layout components render an Outlet for nested routes.

Example:

const Layout = () => (
  <>
    <Header />
    <Outlet />
    <Footer />
  </>
);

...

<Routes>
  <Route element={<Layout />}>
    <Route path='/' element={<Home />} />
  </Route>
</Routes>
about 4 years ago · Juan Pablo Isaza Denunciar

0

You could just extract the <Home/> component from there and provide the layout as a prop to the Route like this

<Route component={Layout} />

And provide your home component inside the Layout component it self

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