firebase - 为什么反应原生地图功能无法正常工作?
问题描述
我正在尝试从 firebase firestore 检索数据。来自 firestore 的数据正在控制台上登录,但在我使用组件时不显示。
renderList = () => {
const { accounts } = this.props
accounts && accounts.map((account) => {
return (
<View>
<Text>{account.accountName}</Text>
{console.log(account.accountName)}
</View>
)
})
}
render() {
return (
<>
{this.renderList()}
</>
)
}
在上面的编码中,console.log(account.accountName) 正在工作,但它没有在 render 方法中打印。我需要使用该数据创建一个列表。
解决方案
请试试这个:
renderList = () => {
const { accounts } = this.props;
if(accounts){
return accounts.map((account) => {
return (
<View>
<Text>{account.accountName}</Text>
{console.log(account.accountName)}
</View>
)
})
}
}
render() {
return (
<>
{this.renderList()}
</>
)
}
希望能帮助到你
推荐阅读
- python - TypeError: ws_connect() got an unexpected keyword argument 'max_msg_size' 在我运行时随机开始出现
- mongodb - 如何使用查找集合中的部分字段进行过滤
- r - 如何在R(dplyr)中添加具有几个现有列的中值的新列?
- xslt - 运行 XSLT (Saxon PE 9.8.0.4J) 时 XML 解析器处理文件报告的 I/O 错误
- javascript - GitHub Pages 网站的运行与使用实时服务器在本地运行时不同
- c# - 如何在 ASP.NET Core 3.1 Web API 中用 SCIM 兼容的模型验证错误详细信息替换 ValidationProblemDetails?
- regex - 使用 RegexTokenizer Scala 标记每个单词仅包含字母的句子
- mongodb - 如何使用聚合展平数组数组
- java - 如何在没有任何公共密钥的情况下在两个 Kafka 主题之间执行数据匹配?
- javascript - 未触发 Javascript 按钮 onclick 事件