0
json(ムービーオブジェクトの配列)のInsight ListViewコンポーネントを表示しようとしていますが、エラーが表示されます。未定義ののcloneWithRowsプロパティを読み取ることができません。私は間違って何をしているのですか?私は多くのチュートリアルを見つけました。それらはすべてハードコードされたデータを使用しており、データが要求から来たときにどのように使用されているのかわかりません。ここに私のコードは次のとおりです。ListViewにjsonを表示
constructor() {
super();
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
this.state = { dataSource: ds.cloneWithRows([]) };
}
componentWillMount() {
axios.get('https://www.omdbapi.com/?s=Batman&page=2')
.then(response => response.data)
.then(this.onAfterLoad)
.catch(this.manageError);
}
// We will update the state of the application so that images can render
onAfterLoad = (data) => {
this.setState({ dataSource: this.ds.cloneWithRows(data.Search) });
};
// If there is an error show error
manageError = (error) => {
Alert.alert('Failure fetching data');
console.error(error);
};
// Description: Render all the titles
// ------------------------------------------------------------------------------------
renderRow(rowData) {
console.log(rowData);
return <Movie key={rowData.imdbID} data={rowData} />;
}
// Description: Render everything to the screen
// ------------------------------------------------------------------------------------
render() {
return (
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderRow}
/>
);
}