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

267
Vistas
How To Remove Nested Array In React Native

I don't know how to remove the nested array in react native. Example :

    Array [
      Array [
        Array [
          "77",
          undefined,
          "Double Pixel Chart",
          "c1",
          "Chart",     
        ],
        Array [
          "78",
          undefined,
          "Heikin Ashi Chart",
          "c2",
          "Chart",      
        ],               
      ],
    ]

What I want is just this array structure :

        Array [
          "77",
          undefined,
          "Double Pixel Chart",
          "c1",
          "Chart",     
        ],
        Array [
          "78",
          undefined,
          "Heikin Ashi Chart",
          "c2",
          "Chart",      
        ],               

This is my code for pushing into the array :

    for (let menu of response.data.Data) {                
            apiChartingMenu = new ApiChartingMenuModel (
                menu.idx,
                menu.shortDescription,
                menu.titlecommand,
                menu.command,
                menu.commandtype,                     
            );                            
            
            data.push(Object.values(apiChartingMenu));
        }  

How can I achieve this?

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

0

You can use plain Javascript by using array.flat(). For your case this could be done as follows.

array = [

   [
      [
      "77",
      undefined,
      "Double Pixel Chart",
      "c1",
      "Chart",     
     ],
     [
      "78",
      undefined,
      "Heikin Ashi Chart",
      "c2",
      "Chart",      
      ],        
   ]
]


console.log(array.flat())

In your case you could make it work by either using

data.push(Object.values(apiChartingMenu).flat());

or by not introducing the object ApiChartingMenuModel at all, since you are just using its values anyway. This could also be done as follows.

// dummy menu object
menu = {

   idx: 77,
   shortDescription: "description",
   titlecommand: undefined,
   command: undefined,
   commandtype: undefined
}


data = []

data.push([menu.idx, menu.shortDescription, menu.titlecommand, menu.command, menu.commandtype])

console.log(data)

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