From 82148da6672e613f34ffb48133cdefc235418dea Mon Sep 17 00:00:00 2001 From: A C SREEDHAR REDDY <acreddysreedharreddy@gmail.com> Date: Tue, 30 Apr 2019 02:22:27 -0700 Subject: [PATCH] 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 --- Libraries/Components/Picker/PickerAndroid.android.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/Picker/PickerAndroid.android.js b/Libraries/Components/Picker/PickerAndroid.android.js index 9dcc8cc10b7ca6..6e82f8c7e94681 100644 --- a/Libraries/Components/Picker/PickerAndroid.android.js +++ b/Libraries/Components/Picker/PickerAndroid.android.js @@ -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); }