@@ -56,11 +56,20 @@ export default class PickerAndroid extends React.Component{
5656 _stateFromProps ( props ) {
5757 let selectedIndex = 0 ;
5858 let items = [ ] ;
59+ let pickerStyle = props . pickerStyle ;
60+ let itemStyle = props . itemStyle ;
61+ let onValueChange = typeof props . onValueChange === function ? props . onValueChange : function ( ) { } ;
5962 React . Children . forEach ( props . children , ( child , index ) => {
6063 child . props . value === props . selectedValue && ( selectedIndex = index ) ;
6164 items . push ( { value : child . props . value , label : child . props . label } ) ;
6265 } ) ;
63- return { selectedIndex, items } ;
66+ return {
67+ selectedIndex,
68+ items,
69+ pickerStyle,
70+ itemStyle,
71+ onValueChange
72+ } ;
6473 }
6574
6675 _move ( dy ) {
@@ -152,7 +161,7 @@ export default class PickerAndroid extends React.Component{
152161
153162 upItems [ index ] = < Text
154163 key = { 'up' + index }
155- style = { [ styles . upText , this . props . itemStyle ] }
164+ style = { [ styles . upText , this . state . itemStyle ] }
156165 onPress = { ( ) => {
157166 this . _moveTo ( index ) ;
158167 } } >
@@ -161,12 +170,12 @@ export default class PickerAndroid extends React.Component{
161170
162171 middleItems [ index ] = < Text
163172 key = { 'mid' + index }
164- style = { [ styles . middleText , this . props . itemStyle ] } > { item . label }
173+ style = { [ styles . middleText , this . state . itemStyle ] } > { item . label }
165174 </ Text > ;
166175
167176 downItems [ index ] = < Text
168177 key = { 'down' + index }
169- style = { [ styles . downText , this . props . itemStyle ] }
178+ style = { [ styles . downText , this . state . itemStyle ] }
170179 onPress = { ( ) => {
171180 this . _moveTo ( index ) ;
172181 } } >
@@ -182,7 +191,7 @@ export default class PickerAndroid extends React.Component{
182191 //but PickerIOS only passed value, so we set label to be the second argument
183192 //add by zooble @2015-12-10
184193 var curItem = this . state . items [ this . index ] ;
185- this . props . onValueChange && this . props . onValueChange ( curItem . value , curItem . label ) ;
194+ this . state . onValueChange ( curItem . value , curItem . label ) ;
186195 }
187196
188197 render ( ) {
@@ -204,7 +213,7 @@ export default class PickerAndroid extends React.Component{
204213
205214 return (
206215 //total to be 90*2+40=220 height
207- < View style = { [ styles . container , this . props . pickerStyle ] } { ...this . _panResponder . panHandlers } >
216+ < View style = { [ styles . container , this . state . pickerStyle ] } { ...this . _panResponder . panHandlers } >
208217
209218 < View style = { styles . up } >
210219 < View style = { [ styles . upView , upViewStyle ] } ref = { ( up ) => { this . up = up } } >
0 commit comments