Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

263
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!