call onValueChange only when value changes (#24653)

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: https://github.com/facebook/react-native/pull/24653

Differential Revision: D15146483

Pulled By: cpojer

fbshipit-source-id: e26f5aa4caa673015c50c853f00b99572e803755
This commit is contained in:
A C SREEDHAR REDDY
2019-04-30 02:22:27 -07:00
committed by Facebook Github Bot
parent 2ef56c025d
commit 82148da667

View File

@@ -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);
}