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

294
Vistas
ReactJS router Matched leaf route at location "/" does not have an element

Matched leaf route at location "/" does not have an element. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.

//App.js File

import {Route, Routes} from 'react-router-dom';
import ProductList from './ProductList';

const App = () => {
  return (

    <Router >
      <Routes>
        <Route
        exact
        path="/"
        render=
        { props => 
        { 
        <ProductList {...props} 
        products={this.state.products} 
        currentCategory={this.state.currentCategory} 
        addToCart={this.addToCart} info={productInfo}/> 
        } }/>
      </Routes>
    </Router>


  )
}

export default App;

When I start adding a route to the program it gives this error, I think the problem is in the render method.

Using a React router

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

0

Your render method is not returning any value. To return a value from an arrow function use () or return or simply omit the {}.

With ()

<Route
  exact
  path="/"
  render=
    { props => 
      { 
        (<ProductList {...props} 
          products={this.state.products} 
          currentCategory={this.state.currentCategory} 
          addToCart={this.addToCart} info={productInfo} />)
      }
    }
/>

With return

<Route
  exact
  path="/"
  render=
    { props => 
      { 
        return <ProductList {...props} 
          products={this.state.products} 
          currentCategory={this.state.currentCategory} 
          addToCart={this.addToCart} info={productInfo} />
      }
    }
/>

Without {}:

<Route
  exact
  path="/"
  render=
    { props => 
      <ProductList {...props} 
        products={this.state.products} 
        currentCategory={this.state.currentCategory} 
        addToCart={this.addToCart} info={productInfo} />
    }
/>
about 4 years ago · Juan Pablo Isaza Denunciar

0

It was fixed by deleting the render and editing it like this.

<Route
  exact
  path="/"
  element={< ProductList products = {
  this.state.products
}
currentCategory = {
  this.state.currentCategory
}
addToCart = {
  this.addToCart
}
info = {
  productInfo
} />}/>
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