如何打印我在控制台上看到的firebase数组元素在网页上显示它们?
这是我第一次使用Firebase。因此,我有点像在控制台中的数据库中获取的数据,但我不知道如何访问数据元素并可能显示它们。
我使用了一个React钩子检索数据。
React.useEffect(() => {
const dbRef=ref(db,"thisIsMyDatabaseString");
onValue(dbRef,(snapshot)=>{
console.log(snapshot.val());
})
},[]);
我可以看到数组元素
我不知道如何在网格中显示它们(我正在使用材料UI)。
任何帮助将不胜感激。 谢谢!
This is my first time using Firebase. So I'm kind of stuck at at point where I can see the data I've fetched from the database in the console but I don't have a clue how to access the data elements and maybe display them.
I used a react hook to retrieve the data.
React.useEffect(() => {
const dbRef=ref(db,"thisIsMyDatabaseString");
onValue(dbRef,(snapshot)=>{
console.log(snapshot.val());
})
},[]);
I can see the array elements
I don't know how to maybe display them in a Grid (I'm using material UI).
Any help would be appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在快照上使用Firebase的内置 foreach :
请注意,这种顺序数字索引是firebase中常见的反图案,因此我也建议您也建议阅读最佳实践:firebase中的阵列。
You can use Firebase's built-in
forEach
on the snapshot:Note that such sequential numeric indexes are a common anti-pattern in Firebase, so I recommend also reading Best Practices: Arrays in Firebase.