Skip to content

Commit

Permalink
Adds extended compare values function (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxpub authored Oct 29, 2021
1 parent 1ee52b2 commit a9b5fb6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export class Select extends Component {
required: PropTypes.bool,
pattern: PropTypes.string,
name: PropTypes.string,
backspaceDelete: PropTypes.bool
backspaceDelete: PropTypes.bool,
compareValuesFunc: PropTypes.func
};

constructor(props) {
Expand Down Expand Up @@ -117,8 +118,8 @@ export class Select extends Component {

componentDidUpdate(prevProps, prevState) {
if (
!isEqual(prevProps.values, this.props.values) &&
isEqual(prevProps.values, prevState.values)
!this.props.compareValuesFunc(prevProps.values, this.props.values) &&
this.props.compareValuesFunc(prevProps.values, prevState.values)
) {
this.setState(
{
Expand Down Expand Up @@ -597,7 +598,8 @@ Select.defaultProps = {
searchFn: () => undefined,
handleKeyDownFn: () => undefined,
additionalProps: null,
backspaceDelete: true
backspaceDelete: true,
compareValuesFunc: isEqual
};

const ReactDropdownSelect = styled.div`
Expand Down

0 comments on commit a9b5fb6

Please sign in to comment.