Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

react native - RNPickerSelect crashes with correct input for items

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.6k users

...