Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

What am I doing wrong with my React Native PickerSelect? It crashed all the time without a warning.

import RNPickerSelect from 'react-native-picker-select';

  getCompanies = () => {
    var items = this.state.companies.map(obj => ({
      key: obj.id,
      label: obj.name,
      value: obj.id,
    }));
    return items;
  };

This is rendered:

<RNPickerSelect
    onValueChange={value =>
      this.setState({company: value})
    }
    items={this.getCompanies()}
  />

But when I open the view where this should be rendered, my App crashes.

question from:https://stackoverflow.com/questions/65848032/rnpickerselect-crashes-with-correct-input-for-items

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.7k views
Welcome To Ask or Share your Answers For Others

1 Answer

Can't comment cause of low reputation.

I had similar issue, make sure "@react-native-picker/picker" is also installed.

for more reference look here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...