From 0abde1ddd00f89acbc710589bb2bffdd068b2c14 Mon Sep 17 00:00:00 2001 From: Peace Date: Fri, 21 Jul 2017 15:40:56 -0500 Subject: [PATCH 1/2] Add prop keyboardShouldPersistTaps to pass to ScrollView. Prop allows compatibility with older and current versions of RN. --- index.js | 13 +++++++------ package.json | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index d65bf4c0..6426c29c 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,7 @@ 'use strict'; -import React,{ - PropTypes -} from 'react'; +import React from 'react'; +import PropTypes from 'prop-types'; import { View, @@ -33,7 +32,8 @@ const propTypes = { cancelStyle: View.propTypes.style, cancelTextStyle: Text.propTypes.style, overlayStyle: View.propTypes.style, - cancelText: PropTypes.string + cancelText: PropTypes.string, + keyboardShouldPersistTaps: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]) }; const defaultProps = { @@ -49,7 +49,8 @@ const defaultProps = { cancelStyle: {}, cancelTextStyle: {}, overlayStyle: {}, - cancelText: 'cancel' + cancelText: 'cancel', + keyboardShouldPersistTaps: 'always' }; export default class ModalPicker extends BaseComponent { @@ -131,7 +132,7 @@ export default class ModalPicker extends BaseComponent { return ( - + {options} diff --git a/package.json b/package.json index 16e1eba7..fff55b63 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,9 @@ "android", "react-component" ], + "dependencies": { + "prop-types": "^15.5.10" + }, "author": "Daniel Korger ", "contributors": [ { From d4c37844e06387b63f332cdc435772ca0cbe681b Mon Sep 17 00:00:00 2001 From: Peace Date: Fri, 21 Jul 2017 16:51:04 -0500 Subject: [PATCH 2/2] Conditionally use ViewPropTypes. View.PropTypes has been deprecated. --- index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 6426c29c..395a282f 100644 --- a/index.js +++ b/index.js @@ -11,27 +11,29 @@ import { Text, ScrollView, TouchableOpacity, - Platform + Platform, + ViewPropTypes } from 'react-native'; import styles from './style'; import BaseComponent from './BaseComponent'; let componentIndex = 0; +let rnVersion = Number.parseFloat(require('react-native/package.json').version); const propTypes = { data: PropTypes.array, onChange: PropTypes.func, initValue: PropTypes.string, - style: View.propTypes.style, - selectStyle: View.propTypes.style, - optionStyle: View.propTypes.style, + style: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, + selectStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, + optionStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, optionTextStyle: Text.propTypes.style, - sectionStyle: View.propTypes.style, + sectionStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, sectionTextStyle: Text.propTypes.style, - cancelStyle: View.propTypes.style, + cancelStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, cancelTextStyle: Text.propTypes.style, - overlayStyle: View.propTypes.style, + overlayStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, cancelText: PropTypes.string, keyboardShouldPersistTaps: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]) };