Skip to content

Commit

Permalink
call onValueChange only when value changes (#24653)
Browse files Browse the repository at this point in the history
Summary:
`OnValueChange` function of `Picker` is called when Picker is initialized.

[Android][fixed] - `OnValueChange` will be called only when the `selectedValue` changes.
Pull Request resolved: #24653

Differential Revision: D15146483

Pulled By: cpojer

fbshipit-source-id: e26f5aa4caa673015c50c853f00b99572e803755
  • Loading branch information
a-c-sreedhar-reddy authored and facebook-github-bot committed Apr 30, 2019
1 parent 2ef56c0 commit 82148da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Libraries/Components/Picker/PickerAndroid.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ class PickerAndroid extends React.Component<
const value = children[position].props.value;
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
* found when making Flow check .android.js files. */
this.props.onValueChange(value, position);
if (this.props.selectedValue !== value) {
this.props.onValueChange(value, position);
}
} else {
this.props.onValueChange(null, position);
}
Expand Down

0 comments on commit 82148da

Please sign in to comment.