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

215
Vistas
React array map inside map value not rendering

I have an object Array list and this array list includes duplicate values. So I need to render only unique values. But it's not working.

{promotions.map((row) => (
  <div>
    <h1>{row.name}</h1>  //This is working
    {row.products.map(() => {
      const pp = row.products.filter( (ele, ind) => ind === row.products.findIndex( elem => elem.productId === ele.productId))

      pp.map((data)=>{
        return(
          <Chip
            key={`${row.productId}_${data.productId}`}
            classes={{ root: classes.productsChipRoot }}
            label={data.productName}
            style={{ margin: 3, backgroundColor: '#BBD7FB' }}
          /> 
        )
      })
    })}
  </div>
))}
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

In Render, Map works for just outter map. So, the Inner map is not render. You should not use the inner map.

I recommend using filter method. Like this

row.products.filter(*condition*).map(()=>{
      return <div></div>
)
about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to return your "pp" returned value correctly.

For example:

let firstArray = [{
  id: 1,
  name: "asd"
}, {
  id: 2,
  name: "fgh"
}];
let secondArray = [{
  id: 1,
  name: "hjk"
}, {
  id: 2,
  name: "zxc"
}];

firstArray.map(() => {
  const pp = firstArray.filter((ele, ind) => ind === firstArray.findIndex(elem => elem.id === 2))

  return pp.map((data) => {
    return (
      console.log(data)
    )
  })
})
about 4 years ago · Juan Pablo Isaza Denunciar

0

{promotions.map((row) => (
      <div>
        <h1>{row.name}</h1>  //This is working
        {row.products.map(() => {
          const pp = row.products.filter( (ele, ind) => ind === row.products.findIndex( elem => elem.productId === ele.productId))
    
          return pp.map((data)=>{
            return(
              <Chip
                key={`${row.productId}_${data.productId}`}
                classes={{ root: classes.productsChipRoot }}
                label={data.productName}
                style={{ margin: 3, backgroundColor: '#BBD7FB' }}
              /> 
            )
          })
        })}
      </div>
    ))}
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