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

147
Vistas
Reading multiple objects, in a single object, with in an array, with unique keys. into FlatList

I am trying to display this data in a FlatList.

Array [
  Object {
    "-N1gqvHXUi2LLGdtIumv": Object {
      "Message": "Aeaaeaea",
      "Message_CreatedAt": 1652167522975,
      "Message_by_Email": "vvvv@test.com",
      "Message_by_ID": "DgGfooQIMQQ1rs5xlmmSKCSTrKA2",
    },
    "-N1hB3A_Q7-K75UbvPSM": Object {
      "Message": "Yyoo",
      "Message_CreatedAt": 1652173063182,
      "Message_by_Email": "vvvjugu@test.com",
      "Message_by_ID": "DgGfooQIMQQ1rs5xlmmSKCSTrKA2",
    },
  },
]

My data looks like this, its multiple objects in a single object within an array, and each object has multiple unique Ids how can I read the data.

My FlatList code

 <FlatList data={data} renderItem={(Item) => <Text>{Item.item. Message}</Text>}

Here the problem is, FlatList is considering the main object and not the children, how can I access and render the children in a Flatlist and how can I access the unique Id.

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

0

You can access the keys of an object (your ids) obj using Object.keys(obj). This returns an array of all the keys included in the given object, eg:

Object.keys(obj).map(key => console.log(key, obj[key])

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

You can also take a closer look at the Object.entries() and Object.values() functions.

about 4 years ago · Juan Pablo Isaza Denunciar

0

you can loop over, every single element, and then. de-structure it and combine the key with the body.

  const data = Onsnapshot.forEach((childSnapshot) => {
        const childKey = childSnapshot.key;
        const childData = childSnapshot.val();
        console.log({ childKey, ...childData });}

then you can you this data in FlatList

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