Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

265
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda