I want to log in user by signInAnonymously and Every user data save their uid My all document is clear but I can't read data from firebase
Please Explain and give some solution.
let ref = firestore()
.collection('users')
.doc(userId)
.collection('lists')
const userId=()=>{ return auth().currentUser.uid; }
hare is My user id and collection of data
const getList = () => {
let newlist = [];
ref.onSnapshot(querySnapshot => {
querySnapshot.forEach(doc => {
newlist.push({
id: doc.id,
...doc.data(),
})
console.log(doc);
})
});
setList(newlist)
}
//
useEffect(() => {
//
//
auth().onAuthStateChanged(user => {
if (user) {
setUser(user)
} else {
auth()
.signInAnonymously()
.catch(err => {})
}
})
}, []);