Skip to content

Commit 849c0b8

Browse files
committed
Conditionally use ViewPropTypes.
1 parent 880e5fb commit 849c0b8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,29 @@ import {
1111
Text,
1212
ScrollView,
1313
TouchableOpacity,
14-
Platform
14+
Platform,
15+
ViewPropTypes
1516
} from 'react-native';
1617

1718
import styles from './style';
1819
import BaseComponent from './BaseComponent';
1920

2021
let componentIndex = 0;
22+
let rnVersion = Number.parseFloat(require('react-native/package.json').version);
2123

2224
const propTypes = {
2325
data: PropTypes.array,
2426
onChange: PropTypes.func,
2527
initValue: PropTypes.string,
26-
style: View.propTypes.style,
27-
selectStyle: View.propTypes.style,
28-
optionStyle: View.propTypes.style,
28+
style: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style,
29+
selectStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style,
30+
optionStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style,
2931
optionTextStyle: Text.propTypes.style,
30-
sectionStyle: View.propTypes.style,
32+
sectionStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style,
3133
sectionTextStyle: Text.propTypes.style,
32-
cancelStyle: View.propTypes.style,
34+
cancelStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style,
3335
cancelTextStyle: Text.propTypes.style,
34-
overlayStyle: View.propTypes.style,
36+
overlayStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style,
3537
cancelText: PropTypes.string,
3638
keyboardShouldPersistTaps: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
3739
};

0 commit comments

Comments
 (0)