-
-
Save streetsmartdev/f07420697fbf686e7ff872d7b897f4e5 to your computer and use it in GitHub Desktop.
RN-LFVL-2 - Remove the DataSource references
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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