@@ -113,7 +113,7 @@ export class CustomPicker extends React.PureComponent<
113
113
{ options . map ( ( o , index ) => (
114
114
< TouchableOpacity
115
115
onPress = { ( ) => {
116
- this . selectOption ( o )
116
+ this . selectOption ( o , true )
117
117
} }
118
118
key = { index }
119
119
>
@@ -139,13 +139,13 @@ export class CustomPicker extends React.PureComponent<
139
139
componentDidMount ( ) {
140
140
const { value, defaultValue } = this . props
141
141
if ( value || defaultValue ) {
142
- this . selectOption ( value || defaultValue )
142
+ this . selectOption ( value || defaultValue , false )
143
143
}
144
144
}
145
145
146
146
componentWillReceiveProps ( nextProps : CustomPickerProps ) {
147
147
if ( nextProps . value !== this . props . value ) {
148
- this . selectOption ( nextProps . value )
148
+ this . selectOption ( nextProps . value , false )
149
149
}
150
150
}
151
151
@@ -181,11 +181,11 @@ export class CustomPicker extends React.PureComponent<
181
181
* Select an option.
182
182
* @param selectedItem Item/option to select.
183
183
*/
184
- selectOption ( selectedItem : any ) {
184
+ selectOption ( selectedItem : any , triggerEvent : boolean ) {
185
185
const { onValueChange } = this . props
186
186
this . setState ( { selectedItem } , ( ) => {
187
187
this . hideOptions ( )
188
- if ( onValueChange ) {
188
+ if ( triggerEvent && onValueChange ) {
189
189
onValueChange ( selectedItem )
190
190
}
191
191
} )
@@ -196,7 +196,7 @@ export class CustomPicker extends React.PureComponent<
196
196
*/
197
197
clear ( ) {
198
198
const { defaultValue } = this . props
199
- this . selectOption ( defaultValue || null )
199
+ this . selectOption ( defaultValue || null , true )
200
200
}
201
201
}
202
202
0 commit comments