简体   繁体   English

嘿,我正在尝试使用 react-native 和 firebase 作为我的主数据库来构建一个博客应用程序

[英]hey i am trying to build a blogging application using react-native and firebase as my primary database

Hey i am trying to build a blog app but i am facing an error in the posting of the blog and i think the error is in the file 'screens/main/Home.js' that says 'Type Error: null is not an object (evaluating quearySnapshot.forEach')'嘿,我正在尝试构建一个博客应用程序,但我在发布博客时遇到错误,我认为错误出现在文件“screens/main/Home.js”中,上面写着“类型错误:null 不是 object (评估 quearySnapshot.forEach')'

source code: https://github.com/Sakshamz4554/reactnativeblogapp源代码: https://github.com/Sakshamz4554/reactnativeblogapp

The above error is due to quearySnapshot in your code is not an array but null.上述错误是由于您的代码中的quearySnapshot不是数组,而是 null。 Before using an array operation to a variable, it's always better to check if its value is not null and have length more than 0 like shown below在对变量使用数组操作之前,最好检查它的值是否不是 null 并且长度大于 0,如下所示

function getBlogData() {
      firestore().collection('usersBlog')
      .doc(auth().currentUser.uid)
      .collection('blogs')
      .onSnapshot((quearySnapshot) => {
         const data = []
         quearySnapshot?.length > 0 && quearySnapshot.forEach((documentSnapshot) => {
            data.push({
               ...documentSnapshot.data(),
               id: documentSnapshot.id
            })
         })
         setBlogs(data)
      })
   }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 嘿,如何使用 react native 和 firebase 创建博客应用程序 - Hey how to create a blogging application using react native and firebase 如何在 firebase 上为 razorpay 创建 order_id? 我正在使用 react-native 和 firebase 进行移动应用程序 - How to create order_id on firebase for razorpay? I am using react-native with firebase for mobile application 如何在 android 和 Z1BDF605991920DB11CBDF850820 的 react-native 应用程序中使用 firebase 成功执行 Google 登录? - How can I successfully perform Google-login using firebase in react-native application for android and iOS both if I am having different client IDs? 我正在尝试将 firebase 集成到我在 expo-cli 中的本机应用程序中 - I am trying to integrate firebase in my react native app in expo-cli 我可以使用 firebase 和 react-native 验证电话号码吗? - Can I verify a phone number using firebase and react-native? 反应本地应用程序构建失败的反应本地firebase - react native app build failing for react-native firebase 我正在尝试使用Firebase为Java桌面应用程序构建后端 - I am trying to use Firebase to build a Backend for a Java Desktop Application Firebase实时数据库错误,尝试在模拟器中运行时我的应用程序已停止 - Firebase real time database error ,My application is stopped when I am trying to run in emulator 在我的反应原生 expo 应用程序中,我可以在哪里找到或生成 Firebase 的 build.gradle? - Where I can find or generate build.gradle for Firebase in my react native expo application? 我正在尝试在我的 React 应用程序中安装 firebase 并收到此错误 - I am trying to install firebase in my react app and getting this error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM