I'm quite new to the framework. I'm making a basic ListView with dataSource in React-Native, with data that I fetch.
constructor(props){
super(props);
var dataSource = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2,
});
this.state = {
searchString: '',
isLoading: false,
message: '',
jsonData: '',
};
}
_fetchData(query){
console.log(query);
this.setState({ isLoading: true });
fetch(query)
.then(response => response.json())
.then(responseData => {
this._handleResponse(responseData);
this.setState({
message: 'seems like it worked!',
dataSource: this.state.dataSource.cloneWithRows( responseData ),
});
})
.catch(error =>
this.setState({
isLoading: false,
message: this.state.message + ' --- ' + 'Something bad happened' + error
})
).done();
}
the data I fetch is an extract from a twitter API response:
{ "statuses": [
{
"coordinates": null,
"favorited": false,
"truncated": false,
"created_at": "Mon Sep 24 03:35:21 +0000 2012",
"id_str": "250075927172759552",
"retweet_count": 0,
"in_reply_to_status_id_str": null,
"id": 250075927172759552
}
]}
yet, I get a "undefined is not an object (evaluating 'dataSource.rowIdentities')" error on cloneWithRows. This error appears when I run the simulation on iOS 8.4 and 9.1. I'm probably missing something small and have been stuck for hours. Any ideas?