Skip to content

Commit

Permalink
Catch networking error
Browse files Browse the repository at this point in the history
  • Loading branch information
race604 committed Sep 30, 2015
1 parent 0174b3e commit ec4388f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ListScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ var ListScreen = React.createClass({
dataSource: dataSouce,
});
})
.catch((error) => {
console.error(error);
this.setState({
isLoading: (isRefresh ? false : this.state.isLoading),
isLoadingTail: (isRefresh ? this.state.isLoadingTail : false),
theme: this.state.theme,
dataSource: this.state.dataSource.cloneWithRows([]),
});
})
.done();
},
getSectionTitle: function(str) {
Expand Down Expand Up @@ -243,7 +252,7 @@ var ListScreen = React.createClass({
},
render: function() {
var content = this.state.dataSource.getRowCount() === 0 ?
<View style={styles.container}></View> :
<View style={styles.centerEmpty}><Text>加载失败</Text></View> :
<ListView
ref="listview"
dataSource={this.state.dataSource}
Expand Down Expand Up @@ -281,6 +290,11 @@ var ListScreen = React.createClass({
});

var styles = StyleSheet.create({
centerEmpty: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
container: {
flex: 1,
flexDirection: 'column',
Expand Down

0 comments on commit ec4388f

Please sign in to comment.