diff --git a/index.js b/index.js index cbef288..863242a 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ 'use strict'; -import React, {Component, PropTypes} from 'react'; +import React, { Component } from 'react'; import { StyleSheet, View, @@ -8,8 +8,10 @@ import { Image, Dimensions, PixelRatio, - PanResponder + PanResponder, + ViewPropTypes, } from 'react-native'; +import PropTypes from "prop-types"; class PickerAndroidItem extends Component{ @@ -34,7 +36,7 @@ export default class PickerAndroid extends Component{ static propTypes = { //picker's style - pickerStyle: View.propTypes.style, + pickerStyle: ViewPropTypes.style, //picker item's style itemStyle: Text.propTypes.style, //picked value changed then call this function @@ -205,7 +207,9 @@ export default class PickerAndroid extends Component{ //but PickerIOS only passed value, so we set label to be the second argument //add by zooble @2015-12-10 var curItem = this.state.items[this.index]; - this.state.onValueChange && this.state.onValueChange(curItem.value, curItem.label); + if (curItem && this.state.onValueChange) { + this.state.onValueChange(curItem.value, curItem.label); + } } render(){ @@ -267,7 +271,8 @@ let styles = StyleSheet.create({ }, up: { height: 90, - overflow: 'hidden' + overflow: 'hidden', + backgroundColor: 'transparent', }, upView: { justifyContent: 'flex-start', @@ -289,7 +294,8 @@ let styles = StyleSheet.create({ overflow: 'hidden', borderColor: '#aaa', borderTopWidth: 1/ratio, - borderBottomWidth: 1/ratio + borderBottomWidth: 1/ratio, + backgroundColor: 'transparent', }, middleView: { height: 40, @@ -307,12 +313,14 @@ let styles = StyleSheet.create({ }, down: { height: 90, - overflow: 'hidden' + overflow: 'hidden', + backgroundColor: 'transparent', }, downView: { overflow: 'hidden', justifyContent: 'flex-start', - alignItems: 'center' + alignItems: 'center', + backgroundColor: 'transparent', }, downText: { paddingTop: 0, diff --git a/package.json b/package.json index b11f4fd..a9bd017 100644 --- a/package.json +++ b/package.json @@ -26,5 +26,8 @@ "bugs": { "url": "https://github.com/beefe/react-native-picker-android/issues" }, - "homepage": "https://github.com/beefe/react-native-picker-android#readme" + "homepage": "https://github.com/beefe/react-native-picker-android#readme", + "dependencies": { + "prop-types": "^15.6.0" + } }