I am trying to pass several arrays through a for loop in the render method and render that data with View. I keep getting an error in sentry.io "undefined is not an object (evaluating 't.number[o]')"
I am pretty new to this and any help would be appreciated!
render() {
const userInfo = this.state.userInfo;
const thisArray = this.state.thisArray;
var myloop = [];
for (let i = 0; i < 2; i++) {
const totals = thisArray[i].number;
const yourNumber = userInfo.number[i].enrolledNumber;
myloop.push(
<View key={i}>
<Separator />
<Text style={[styles.content, { fontSize: 20 }]}>
{thisArray[i].name}
</Text>
</View>
)
}
return (
<SafeAreaView style={styles.container}>
<ScrollView>
<View style={styles.container}>
<Text style={styles.txtColor}>Data</Text>
{myloop}
</View>
</ScrollView>
</SafeAreaView>
);
}
I am getting the following error
undefined is not an object (evaluating 'thisArray[i].number')
Does anyone have thoughts?
thisArray.length. YourthisArraydoesn't have an index 1 or 2.