Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未使用值填充反应本机列表_Javascript_User Interface_React Native - Fatal编程技术网

Javascript 未使用值填充反应本机列表

Javascript 未使用值填充反应本机列表,javascript,user-interface,react-native,Javascript,User Interface,React Native,我目前正在react native中构建一个列表,但不幸的是,它没有填充任何值。有4个列表元素与数组中的数字一致。但是这些项在界面中只是空的 render(){ console.log(this.state.friends); /*日志[ 排列[ 反对{ “阿凡达url”:爱丽丝url, “id”:1, “姓名”:“爱丽丝”, “选定”:false, }, 反对{ “阿凡达url”:鲍勃url, “id”:2, “姓名”:“鲍勃”, “选定”:false, }, 反对{ “阿凡达url”:查理

我目前正在react native中构建一个列表,但不幸的是,它没有填充任何值。有4个列表元素与数组中的数字一致。但是这些项在界面中只是空的

render(){
console.log(this.state.friends);
/*日志[
排列[
反对{
“阿凡达url”:爱丽丝url,
“id”:1,
“姓名”:“爱丽丝”,
“选定”:false,
},
反对{
“阿凡达url”:鲍勃url,
“id”:2,
“姓名”:“鲍勃”,
“选定”:false,
},
反对{
“阿凡达url”:查理url,
“id”:3,
“姓名”:“查理”,
“选定”:false,
},
反对{
“阿凡达url”:Dave url,
“id”:4,
“姓名”:“戴夫”,
“选定”:false,
},
]]*/
返回(
{
this.state.friends.map((l,i)=>{
返回({this.clickedFriend(l)}
title={l.name}
rightIcon={}
/>)
})
}
{/*{this.inviteFriends()}}
title=“邀请朋友”
/> */}
this.send()}>
发送
);

}
我想这是因为map函数没有返回任何内容。映射确实映射到4个项,因此对于listView项,但不返回任何内容。在map函数中,尝试将您的输入放在一个return(/ListItem here/)中,如下所示

{
            this.state.friends.map((l, i) => (
              return(<ListItem
                roundAvatar
                avatar={{uri: l.avatar_url}}
                key={i}
                onPress={() => {this.clickedFriend(l)}}
                title={l.name}
                rightIcon={<Icon style={{alignSelf: 'center'}} size={25} name={l.selected ? "check-circle-o" : "times-circle-o"}/>}
              />)
            ))
          }
{
this.state.friends.map((l,i)=>(
返回({this.clickedFriend(l)}
title={l.name}
rightIcon={}
/>)
))
}

你能分享ListItem的代码吗?实际上还没有,让我更新问题中的代码。哎呀!请尝试此操作,只需在映射起始行之前添加/*return*/即可。因此,它将
返回此.state.friends.map((l,i)=>(……
请务必让我知道它是否有效,以便我可以编辑我的答案。实际上仍然没有:/n现在实际发现问题。感谢您的帮助!这是因为我在使用本机库中的List和ListItem,而我本应使用from React本机元素。