Skip to content

Commit

Permalink
onChange should fire only for valid option with key (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
peacechen committed Jul 7, 2021
1 parent 34245a1 commit 825d94d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ export default class ModalSelector extends React.Component {
}

onChange = (item) => {
if (!item || !item.key) {
return;
}
this.props.onChange(item);
this.setState({ selected: this.props.labelExtractor(item), changedItem: item }, () => {
if (this.props.closeOnChange)
Expand Down

0 comments on commit 825d94d

Please sign in to comment.