React Native Picker select: are there any callbacks available for Android?

529 Views Asked by At

I'm using react-native-picker-select in my React Native app, and the two main callbacks I'm using for iOS are onClose() and onDonePress(). However, these are iOS only. Is there some approach you can use with Android to trigger a function when the user has closed the picker or pressed Done? I know you can use onValueChange(), but this doesn't get triggered when the user is done, just when they iterate through the options in the picker.

1

There are 1 best solutions below

0
On

onClose is iOS only, I was able to get a similar behavior for Android using onBlur of touchableWrapperProps (please make sure to add fixAndroidTouchableBug).

const handleOnClose = () => {};

<RNPickerSelect
          onClose={handleOnClose} // iOS only
          fixAndroidTouchableBug
          touchableWrapperProps={{ onBlur: handleOnClose }} // Android only
        />