1

I am using React Native Picker Select and I don't know if it's intended to show only one item in Picker but, let's say I have only one item in the items array and no placeholder. How can I trigger onValueChange since there is only one item and no change at all.

In IOS it's easy, I can do onClose or onDonePress to get selected value in the picker even if there is only one item, but; in android I couldn't find a way to achieve that. Don't hesitate to share code snippet, documents, articles etc.

Thanks in advance.

 const expendableItems = [{label: 'JustONeItem', value: item}];

 <RNPickerSelect
        onValueChange={onValueChange}
        onClose={onClose}
        placeholder={placeholder}
        items={expendableItems}
        Icon={() => null}
  />
Erkin Kurt
  • 652
  • 6
  • 16
  • Given that you have the array why not set the item as value if the array contains only one item ? – Guruparan Giritharan May 29 '20 at 17:25
  • Even if I set the value, it doesn't trigger the onValueChange when user tap the item in selector. Did I misunderstand your comment? Can you provide more detail? – Erkin Kurt May 31 '20 at 00:26
  • What i meant is why trigger the onvalue change if its only one item? can set it as default value and do the required processing in componentdidmount, just an idea :) – Guruparan Giritharan May 31 '20 at 04:22

0 Answers0