I have an array that I need to map out in <Text>. This is what I've got in render()
categories.map(category => <Text>{category.testHeader}</Text>
But it doesn't print anything. I guess <Text> needs to be in render() right? So I tried adding it in a function to be called in render. Like this:
function myfunc() {
return categories.map(category => <Text>{category.testHeader}</Text>)
}
Then in render():
<View>
{myfunc()}
</View>
But then the compiler said `Cannot read property 'map' of undefined. SO tips told me to put write:
function myfunc() {
if (this.props.data) {
return categories.map(category => <Text>{category.testHeader}</Text>)
}
}
But now the compiler tells me that data is undefined. Not sure what to do here... :/
categories, where it come from ? should be props, local state, private variable, etc. do you meanthis.props.data.categories?