私は反応ネイティブで1ページのアプリケーションを作成しています。フェッチレスポンスをリストビューで表示したい。応答アレイにアクセスするために、私は、マップ・メソッドを使用していますがReactネイティブタイプエラー:this.props.data.mapは関数ではありません
は次のようにこの{
"responseHeader": {
"type": "314",
"status": "200",
"message": "Successfully found the profile"
},
"neighbourProfile": [{
"no_of_mutual_friends": "0",
"username": "Amith Issac",
},
{
"no_of_mutual_friends": "0",
"username": "Liz",
}]
}
ここでmapメソッドを使用する方法
?そして、私のapp.jsのように私のサーバーを見てから上記error.The応答がありました私は何が間違っを
app.js
import React, { Component } from 'react';
import { ScrollView } from 'react-native';
import Neighbour from './src/components/Neighbour';
class App extends Component {
state = { neighbours: [] };
componentWillMount(){
const myArray =
{"requestHeader":
{
"personal_id": "122334",
"type":"314"
}
}
fetch(" https://xxxxx",{
method: 'POST',
headers:{
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(myArray)
})
.then((response) => response.json())
.then((responseData) =>this.setState({neighbours: responseData}));
}
renderNeighbour(){
return this.state.neighbours.map(neighbours =>
<Neighbour key ={neighbours.username} neighbours={neighbours}/>
);
}
render() {
return (
<ScrollView>
{this.renderNeighbour()}
</ScrollView>
);
}
}
export default App;
をやっていますか?
あなたは、リストビューコンポーネントを使用していますか?あなたはneighbourProfileの権利からマップしたいですか? –
私はこのマップ方法を使用しているため、応答を記載したい – anu