I'm working with react-native-db-models node module. I have 3 rows on my database model. => ( title | privateid | action )
I lose 2 days for this workout. I want to list all records from database. What's wrong?
var Download = React.createClass({
getInitialState: function () {
return {
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2,
})
};
},
componentDidMount: function() {
this.fetchData();
},
fetchData: function () {
DB.downloads.get_all(function(result) {
var data = [];
for(var i = 1; i <= result.totalrows; i++) {
console.log(result.rows[i]);
data[i-1] = result.rows[i];
this.setState({
dataSource: dataSource.cloneWithRows(result.rows[i]),
loaded:false,
})
}
});
},
render: function () {
return (
<ListView
dataSource={this.state.dataSource}
renderRow={this.renderTrack}
style={styles.listView}/>
);
},
renderTrack: function (track) {
return (
<View>
<Text>{track.title}</Text>
</View>
);
}
});