Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RN-LFVL-2 - Remove the DataSource references
export default class Application extends Component {
constructor(props) {
...
this.state = {
dataSource: null, // remove this dataSource
isLoading: true,
isLoadingMore: false,
_data: null,
_dataAfter: ""
};
}
...
_fetchMore() {
this.fetchData(responseJson => {
const data = this.state._data.concat(responseJson.data.children);
this.setState({
dataSource: this.state.dataSource.cloneWithRows(data), //Remove this cloneWithRows
isLoadingMore: false,
_data: data,
_dataAfter: responseJson.data.after
});
});
}
componentDidMount() {
this.fetchData(responseJson => {
//Remove the creation of ListView.DataSource instance
//let ds = new ListView.DataSource({
// rowHasChanged: (r1, r2) => r1 !== r2
//});
const data = responseJson.data.children;
this.setState({
dataSource: ds.cloneWithRows(data), //remove this dataSource reference
isLoading: false,
_data: data,
_dataAfter: responseJson.data.after
});
});
}
render() {
if (this.state.isLoading) {
...
} else {
return (
<FlatList
dataSource={this.state.dataSource} //Remove this reference to dataSource
renderRow={rowData => {
...
}}
...
/>
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.