From f8a9621bf3e883cd7f9c102dc0b15c8c700366e1 Mon Sep 17 00:00:00 2001 From: Peace Date: Tue, 3 Oct 2017 12:12:06 -0500 Subject: [PATCH] Improved method of supporting old & new versions of RN. --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 7b64fc6..b327785 100644 --- a/index.js +++ b/index.js @@ -7,10 +7,10 @@ import { Text, TextInput, View, - ViewPropTypes + ViewPropTypes as RNViewPropTypes } from 'react-native'; -let rnVersion = Number.parseFloat(require('react-native/package.json').version); +const ViewPropTypes = RNViewPropTypes || View.propTypes; class Autocomplete extends Component { static propTypes = { @@ -19,7 +19,7 @@ class Autocomplete extends Component { * These styles will be applied to the container which * surrounds the autocomplete component. */ - containerStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, + containerStyle: ViewPropTypes.style, /** * Assign an array of data objects which should be * rendered in respect to the entered text. @@ -33,7 +33,7 @@ class Autocomplete extends Component { * These styles will be applied to the container which surrounds * the textInput component. */ - inputContainerStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, + inputContainerStyle: ViewPropTypes.style, /* * Set `keyboardShouldPersistTaps` to true if RN version is <= 0.39. */ @@ -45,7 +45,7 @@ class Autocomplete extends Component { * These styles will be applied to the container which surrounds * the result list. */ - listContainerStyle: rnVersion >= 0.44 ? ViewPropTypes.style : View.propTypes.style, + listContainerStyle: ViewPropTypes.style, /** * These style will be applied to the result list. */