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

map function in React-Native

$
0
0

I am new to React Native and I am using Typescript for my project. I am difficulty to do mapping in React Native. Below is my code for interface:

interface Teacher {  name: string;  sex: string;  age: number;  student: Student[];}interface Student {  name: string;  sex: string;  address: string;}

I don't have any problem mapping Teacher's interface but I am having difficulty on how to map Student interface when I use the map function in my code.

{Class.map(class => (<View>      {class.student.map(class => (<Text>{class.name}</Text>      ))}      {class.student.map(class => (<Text>{class.sex}</Text>      ))}      {class.student.map(class => (<Text>{class.address}</Text>      ))}</View>)}

When I did my coding like this, I get an error Cannot read property 'map' of undefined in my console. Thank you 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>