@@ -5,12 +5,13 @@ import isEqual from 'lodash.isequal';
55import { Picker } from '@react-native-picker/picker' ;
66import { defaultStyles } from './styles' ;
77import { Dimensions } from 'react-native' ;
8-
9- // Measuring the modal before rendering is not working reliably, so we need to hardcode the height
10- // This height was tested thoroughly on several iPhone Models (from iPhone 8 to 14 Pro)
11- const IOS_MODAL_HEIGHT = 262 ;
8+ import { PickerAvoidingView } from "./PickerAvoidingView" ;
9+ import { PickerStateContext , PickerStateProvider } from "./PickerStateProvider" ;
10+ import { IOS_MODAL_HEIGHT } from "./constants" ;
1211
1312export default class RNPickerSelect extends PureComponent {
13+ static contextType = PickerStateContext ;
14+
1415 static propTypes = {
1516 onValueChange : PropTypes . func . isRequired ,
1617 items : PropTypes . arrayOf (
@@ -275,6 +276,10 @@ export default class RNPickerSelect extends PureComponent {
275276 const animationType =
276277 modalProps && modalProps . animationType ? modalProps . animationType : 'slide' ;
277278
279+ if ( this . context ) {
280+ this . context . setIsPickerOpen ( ! showPicker ) ;
281+ }
282+
278283 this . triggerOpenCloseCallbacks ( ) ;
279284
280285 this . setState (
@@ -617,4 +622,4 @@ export default class RNPickerSelect extends PureComponent {
617622 }
618623}
619624
620- export { defaultStyles } ;
625+ export { defaultStyles , PickerStateProvider , PickerAvoidingView } ;
0 commit comments