0

I do not know how to disable the user from interacting with a PickerIOS using react-native, and there does not seem to be much documentation about it out there. More importantly, I only need it to be disabled or not when the element is initially rendered.

A possible solution would be to use a <Text> instead, like so:

{isDisabled? <Text>{...}</Text> : <PickerIOS>{...}</PickerIOS>}

but maybe there's a simpler way out there. Can anyone help?

ldd
  • 99
  • 1
  • 2
  • 9

1 Answers1

1

So long as you use this.state.isDisabled this seems like a perfectly fine solution.

{this.state.isDisabled ? <Text>{...}</Text> : <PickerIOS>{...}</PickerIOS> }

along with..

this.setState({isDisabled:true})

Ben Clayton
  • 80,996
  • 26
  • 120
  • 129
  • yup, I agree, for my use case this looks very clean. On the other hand, it is weird that you cannot disable a PickerIOS component. Maybe I should ask for it as a feature? – ldd Feb 10 '16 at 23:23
  • You might be able to use setNativeProps along with setUserInteractionEnabled and setAlpha - see this answer http://stackoverflow.com/questions/2377692/disable-uipickerview – Ben Clayton Feb 11 '16 at 09:04