InstagramClone: firestore propery undefined in fetchUsersFollowingPosts(uid)

https://github.com/SimCoderYoutube/InstagramClone/blob/e42308ee5fc186310bab10d4f1dfc955604c842f/frontend/redux/actions/index.js#L102 This line of code in the redux action folder inside the fetchUsersFollowingPosts(uid) function is responsible for fetching the individual posts of the users that the user is following, specifically getting the uid that we looked for but within the scope of the returned promise…

it seems like the current expo and firebase SDK doesn’t recognize what the .EP property is.

according to the firestore api reference there is no EP property, could this be a specific reference into your own development environment or is it deprecated?

for reference FireStore: https://firebase.google.com/docs/reference/node/firebase.firestore Query.get(): https://firebase.google.com/docs/reference/node/firebase.firestore.Query#get QuerySnapshot: https://firebase.google.com/docs/reference/node/firebase.firestore.QuerySnapshot QueryDocumentSnapshot: https://firebase.google.com/docs/reference/node/firebase.firestore.QueryDocumentSnapshot

my package.json: “@react-native-community/masked-view”: “0.1.10”, “@react-navigation/bottom-tabs”: “^5.11.7”, “@react-navigation/material-bottom-tabs”: “^5.3.13”, “@react-navigation/native”: “^5.9.2”, “@react-navigation/stack”: “^5.14.1”, “expo”: “~40.0.0”, “expo-camera”: “~9.1.0”, “expo-image-picker”: “^10.0.0”, “expo-status-bar”: “~1.0.3”, “firebase”: “^8.2.4”, “react”: “16.13.1”, “react-dom”: “16.13.1”, “react-native”: “https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz”, “react-native-gesture-handler”: “^1.9.0”, “react-native-paper”: “^4.7.1”, “react-native-reanimated”: “~1.13.0”, “react-native-safe-area-context”: “3.1.9”, “react-native-screens”: “~2.15.2”, “react-native-vector-icons”: “^8.0.0”, “react-native-web”: “~0.13.12”, “react-redux”: “^7.2.2”, “redux”: “^4.0.5”, “redux-thunk”: “^2.3.0”

Youtube timestamp: https://youtu.be/1hPgQWbWmEk?t=14880 Thanks a lot! I’m a huge fan

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 27 (1 by maintainers)

Commits related to this issue

Most upvoted comments

well i got the answer from the internet you can check it out form stackoverflow 👇👇👇👇👇 https://stackoverflow.com/a/68456060/14078264

Hi!

I have tried to emulate the problem without success. But I’m trying to push an update for this ASAP.

The problem arises because there is no documented way of getting the ID of each object from the querySnapshot when you get the doc using an onSnapshot query. This is the “hack” I found that allows this. I’ll be trying to push an update for this week

I’m pretty sure you can get the ID from the document reference from the docs collection snapshot.docs[0].ref.path.split('/')[1]

that’s because there is no such thing as ‘id’ on the user.

I think you should console.log(snapshot) for yourself and try to find the segments data based on the console.log, the snapshot data might be different because firebase might update their way to display the snapshot. For my part i was able to retrieve the data from snapshot…query.C.path.segments[1];

A potential solution is to use:

const uid = snapshot.docs[0].ref.path.split('/')[1];

and put that line^ and the rest of the code in that function in a try catch block. The line above will throw an error if there is no documents (posts), so for users where this throws an error, just catch, and do nothing since its pointless to get the posts of a user with no posts.