Skip to content

Commit

Permalink
Call onChange unconditionally to fix callback for iOS (#97)
Browse files Browse the repository at this point in the history
This may have a side effect of firing onChange twice on iOS.
  • Loading branch information
jacobkring authored Mar 10, 2020
1 parent e2b5ad7 commit 86c6ed2
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ export default class ModalSelector extends React.Component {
}

onChange = (item) => {
if (Platform.OS === 'android' || (Modal.propTypes !== undefined && !Modal.propTypes.onDismiss)) { // don't know if this will work for previous version, please check!
// RN >= 0.50 on iOS comes with the onDismiss prop for Modal which solves RN issue #10471
this.props.onChange(item);
}
this.props.onChange(item);
this.setState({ selected: this.props.labelExtractor(item), changedItem: item }, () => {
if (this.props.closeOnChange)
this.close(item);
Expand Down

0 comments on commit 86c6ed2

Please sign in to comment.