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}/>
);
}
私はエミュレータで実行をしようとしていた場合、このエラーが表示されます。 このエラーを修正する方法を教えてください。 マップ機能がデータを取得できないようです。あなたのフェッチは最初this.props.data
が未定義のレンダリング時には、非同期であるため、23