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

148
Vistas
Interact over object of arrays React JS

I have an object like this one:

[
    {
        "periodname": "Test",
        "periodtime": ""
    },
    {
        "periodname": "",
        "periodtime": ""
    }
]

And I want to render a Col for each array inside of it. My React code:

function renderMyPage(props) {

const { myObject } = props

const renderMyPage = () => {
     return [myObject].map((c,i) => {
        return(
            <Col>
              My data here  
            </Col>
          )
       })
    }
}

But I always get only one result, even if I have two or more arrays inside my object.

If I interact again with map or foreach I get the same object. If I use the map function without using "[]" on the object I get an error:

Uncaught TypeError: Cannot read property 'map' of undefined

What I'm doing wrong to get only one result? Tried a lot of other questions around StackOverflow questions but I'm getting the same result.

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

0

As a quick solution try

const renderMyPage = () => {
     return myObject?.map((c,i) => {
        return(
            <Col>
              My data here  
            </Col>
          )
       })
    }
}

or

const renderMyPage = () => {
     if (!myObject) return null;
    
     return myObject.map((c,i) => {
        return(
            <Col>
              My data here  
            </Col>
          )
       })
    }
}
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