我正在尝试在react-native中创建一个选取器,但我收到一个错误: Error view 'items‘of a view by: AndroidDialogPicker
空
标签的值不能从ReadableNativeMap转换为字符串
我该如何解决这个问题?
constructor(props) {
super(props);
this.state = {
categories: [
{
"description": "Meditações com foco na Respiração",
"id": 1,
"name": "Respiração"
},
{
"description": "Meditações que projetam atenção nos sentidos e percepções do corpo, do ambiente.",
"id": 2,
"name": "Sensitiva"
},
{
"description": "Meditação ativa, pode ser feita em durante outras atividades",
"id": 3,
"name": "Ativa"
}]
};
}
render() {
return(
<Picker
mode="dialog"
iosIcon={<Icon name="arrow-down" />}
placeholder="Select your SIM"
selectedValue={this.state.categorySelected}
onValueChange={this.onValueChange.bind(this)}>
{this.state.categories.map((item, index) => {
return (<Picker.Item label={item} value={index} key={index}/>) })}
</Picker>
)}发布于 2020-06-29 11:45:35
该错误是由于对标签使用对象导致的,该对象在尝试映射到本机代码中的标签时失败。您必须将标签设置为item.name,如下所示。
<Picker.Item label={item.name} value={index} key={index}/> https://stackoverflow.com/questions/62630609
复制相似问题