Reputation: 35
I am trying to use hooks in order to update the state of a list of data. I am using react native. I dont even know what custom Q object is. :/
function userStoresList() {
const [userStores, userStoresUpdate] = useState([]);
const uid = firebase.auth().currentUser;
useEffect(() => {
firebase
.firestore()
.collection('users')
.doc(uid)
.collection('stampcards')
.onSnapshot(snapshot => {
const newUserStores = snapshot.docs.map(doc => ({
id: doc.id,
...doc.id(),
}));
userStoresUpdate(newUserStores);
});
}, []);
return userStores;
}
function UserStampScreen() {
console.log('Initial Render (step 1)');
const userStores = userStoresList();
{userStores.map(store => (
<StampCards
key={store.id}
name={store.name}
promotion={store.promotion}
stamps="5/10 Stamps"
image={store.image}
/>
))}
I am trying to understand why it is outputting this error: Error
If you guys need more information, just ask. np
Upvotes: 0
Views: 2670
Reputation: 4465
firebase.auth().currentUser
does not return just the uid, but rather an object that contains the uid.
You can just change:
const uid = firebase.auth().currentUser
to
const { uid } = firebase.auth().currentUser
Upvotes: 1