state = { HomePage: [] };
componentDidMount() {
axios.get('http://xxxxxx')
.then(response => {
this.setState( {HomePage: response.data})
})
}
renderImage() {
return (
this.state.HomePage.map(Music => <Text>{Music.Name}</Text>)
)
}
我在本节中调用状态,但是当运行项目出错时
<View style={{flex:1}}>
{this.renderImage()}
</View>
TypeError:未定义不是对象(正在评估“ this.state.HomePage.map”)