I can't pull data from react native firebase, the hook always returns anyone. I'm not getting any errors either.
Firebase data is available but I can't seem to connect to firebase. I think we are not able to communicate with firebase. How can I understand this? It was a working function days ago
import { View, Text } from 'react-native'
import React,{useState,useEffect} from 'react'
import auth, { firebase } from '@react-native-firebase/auth';
import database from '@react-native-firebase/database'
export default function DataRef() {
const [list, setList] = useState([]);
function getComments() {
//const user = firebase.auth().currentUser.uid;
const db = firebase.database();
const ref = db.ref('Post/');
ref.once("value", snapshot => {
li = [];
if (snapshot.val()) {
snapshot.forEach(child => {
li.push({
id: child.val().id,
nameSurname: child.val().nameSurname,
postTime: child.val().postTime,
text: child.val().text,
title: child.val().title,
category: child.val().category,
follow: child.child('Follow/count').val(),
commentCount: child.child('comments').numChildren(),
})
});
console.log(li)
setList(li)
}
}
)
}
useEffect(() => {
getComments()
}, [])
return (
<View>
<Text>DataRef</Text>
</View>
)
}