Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

Mapping an array inside an array

$
0
0

I am trying to map an array of data, but keep getting the error: Cannot read property 'map' of undefined for this line: {number.s[0].l['serial'].map(option => This is my code:

{this.state.serials.map((number) => {    return number.s && number.s.length?     (<h2 > {number.s[0].za}</h2><ul>        {number.s[0].l['serial'].map(option => <li>{option}</li>        )}</ul>    ) : null})}

This is my data:

[   {"s": [            {"l": [                     { "serial":"49:42:06:00:20:4e" },                      { "serial":"49:42:06:00:3b:29" }                   ],"za":"900"            }          ]   },   {"s": [            {"l": [{ "serial":"777" }],"za":"5559"            }          ]   }]

Does anyone know how I should define the path to map serials from "l"? I defined it in many different ways, however, I can't seem to get it working.

Thanks in advance!


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>