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.