Skip to content

Commit

Permalink
Improved method of supporting old & new versions of RN.
Browse files Browse the repository at this point in the history
  • Loading branch information
peacechen authored and mrlaessig committed Oct 4, 2017
1 parent be14bf9 commit f8a9621
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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.
Expand All @@ -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.
*/
Expand All @@ -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.
*/
Expand Down

0 comments on commit f8a9621

Please sign in to comment.