【发布时间】:2017-12-02 08:50:59
【问题描述】:
TypeError: undefined is not an object (evaluating 'this.props.data.map')
appBodyData:
render(){
let articles =this.props.data.map(function(articleData,index) {
return (
<Card>
<CardItem>
<Body>
<Text>
{articleData.address.city}
</Text>
</Body>
</CardItem>
</Card>
)
});
return (
<Content>
{articles}
</Content>
);
}
**[appBody:][1]**
getData(){
return fetch("https://jsonplaceholder.typicode.com/users")
.then((response) => response.json())
.then((responseJson) => {
this.setState({data:responseJson.array});
})
.catch((error) => {
console.error(error);
});
}
componentDidMount(){
this.getData();
}
render() {
return (
<AppBodyData data={this.state.data}/>
);
}
当我尝试在模拟器中运行时显示此错误。 我该如何解决这个错误。 似乎地图功能无法获取数据。 反应本机cli版本:50 SDK版本:23
【问题讨论】:
标签: json react-native