Skip to content

Commit

Permalink
add deep equal
Browse files Browse the repository at this point in the history
  • Loading branch information
ruoru committed Feb 5, 2018
1 parent 7a0c04a commit 3ae76c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"homepage": "https://github.com/weui/react-weui",
"dependencies": {
"babel-runtime": "^6.18.0",
"fast-deep-equal": "^1.0.0",
"prop-types": "^15.5.10",
"react": "^16.2.0",
"react-dom": "^16.2.0",
Expand Down
13 changes: 8 additions & 5 deletions src/components/picker/cascade_picker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import GroupPicker from './group_picker';
import equal from 'fast-deep-equal';


class CascadePicker extends React.Component {
Expand Down Expand Up @@ -45,11 +46,13 @@ class CascadePicker extends React.Component {
}

componentWillReceiveProps(nextProps){
const { columns, newSelectIndexs } = this.parseData(nextProps.selectIndexs, nextProps);
this.setState({
columns,
selectIndexs: newSelectIndexs,
});
if(!equal(this.props.data, nextProps.data)) {
const { columns, newSelectIndexs } = this.parseData(nextProps.selectIndexs, nextProps);
this.setState({
columns,
selectIndexs: newSelectIndexs,
});
}
}

parseData(selectIndexs = [], props){
Expand Down

0 comments on commit 3ae76c0

Please sign in to comment.