0
我有反应成分,如:反应从一个数组渲染值给出错误
class UserList extends Component {
render() {
const {users} = this.props
users.forEach(function(user){
console.log(user.name)
if(user.photos){
console.log(user.photos.data[0].source)
return (
<div>
<p>{user.name}</p>
</div>
)
}
})
}
}
export default UserList
但它给我错误说should return valid react component but returned array or undefined
..
返回函数返回的组件吗?
我在这里错过了什么?
如何检查是否有用户照片。如果它有那么只有我要回.. – gamer
的'.filter'将采取照顾。 –
如果没有照片,我不想显示名称..也''照片'包含'图像'像'照片[0]照片[1]'那么如何显示它们的名称? – gamer