Skip to content

Commit

Permalink
not emit fetch when there is no dataSource change, ant-design#347
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Sep 25, 2015
1 parent 094ae9b commit 05347da
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions components/table/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,25 @@ let AntTable = React.createClass({
},

componentWillReceiveProps(nextProps) {
let newState = {};
if (('pagination' in nextProps) && nextProps.pagination !== false) {
newState.pagination = objectAssign({}, this.state.pagination, nextProps.pagination);
this.setState({
pagination: objectAssign({}, this.state.pagination, nextProps.pagination)
});
}
// 外界只有 dataSource 的变化会触发新请求
if ('dataSource' in nextProps &&
nextProps.dataSource !== this.props.dataSource) {
newState = objectAssign(newState, {
this.setState({
selectedRowKeys: [],
dataSource: nextProps.dataSource,
loading: true
});
}, this.fetch);
}
if (nextProps.columns !== this.props.columns) {
newState.filters = {};
this.setState({
filters: {}
});
}
this.setState(newState, this.fetch);
},

hasPagination(pagination) {
Expand Down

0 comments on commit 05347da

Please sign in to comment.