![](/img/trans.png)
[英]How to get all documents but one from firebase firestore in react native?
[英]React Native Firebase: How can you display a text from Firestore?
我正在嘗試使用 React native Firebase 和 Expo 制作一個應用程序,顯示從 Firestore 加載的文本。
例如:我希望應用顯示“helloworld”。 所以我的 Firebase 后端看起來像這樣:在此處輸入圖像描述
但我不知道如何將文本從 Firestore 加載到應用程序中以及如何顯示它。
如果你能幫助我,那就太好了。
謝謝
首先添加庫'react-native-firebase'
import firebase from 'react-native-firebase';
然后使用下面的 function 從 firestore 獲取數據
getDataFromFirebase(){
firebase.firestore().collection('testcollections').doc(testdoc).get()
.then((doc) => {
if (doc.exists) {
console.log("Document data: ", doc.data().testfield);
}else{
console.log("Document data is not empty: ");
}
})
.catch(error => {
console.log('firebase Error::'+error)
})
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.