Skip to content

Commit 82148da

Browse files
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: #24653 Differential Revision: D15146483 Pulled By: cpojer fbshipit-source-id: e26f5aa4caa673015c50c853f00b99572e803755
1 parent 2ef56c0 commit 82148da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Libraries/Components/Picker/PickerAndroid.android.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ class PickerAndroid extends React.Component<
119119
const value = children[position].props.value;
120120
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was
121121
* found when making Flow check .android.js files. */
122-
this.props.onValueChange(value, position);
122+
if (this.props.selectedValue !== value) {
123+
this.props.onValueChange(value, position);
124+
}
123125
} else {
124126
this.props.onValueChange(null, position);
125127
}

0 commit comments

Comments
 (0)