InstagramClone
InstagramClone copied to clipboard
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
just figured out this is a repost of https://github.com/SimCoderYoutube/InstagramClone/issues/16 from a week ago. I'm going to leave this open in case I can find a solution / or to be able to merge a solution
Have you found any solutions?
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 this week
Guys have you solved this??
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]
it gives an error friend @digimbyte
i have the same problem
snapshot.docs[0].ref.path.split('/')[1]
This is the solution!!!! I am getting the UID now. Still had some errors with props.usersState.users but I think this is a different problem.
Thanks SimCoderYoutube/InstagramClone
On Sun., Apr. 18, 2021, 5:39 a.m. Jushua Valencia, @.***> wrote:
snapshot.docs[0].ref.path.split('/')[1]
This is the solution!!!!
β You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SimCoderYoutube/InstagramClone/issues/19#issuecomment-821955683, or unsubscribe https://github.com/notifications/unsubscribe-auth/APZJ2JPPCBETOGMIXFQWKATTJKLDRANCNFSM4W6VPCUA .
for reference, I run a Firebase Community on Discord - we had a user who had the same issue, the error proceeding is related to something else in the project. https://discord.firebase.me/
Hi, here is the error I am getting[image: Capture.PNG]
Le dim. 18 avr. 2021 Γ 07:21, DIGI Byte @.***> a Γ©crit :
for reference, I run a Firebase Community on Discord - we had a user who had the same issue, the error proceeding is related to something else in the project. https://discord.firebase.me/
β You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SimCoderYoutube/InstagramClone/issues/19#issuecomment-821968811, or unsubscribe https://github.com/notifications/unsubscribe-auth/APZJ2JIA4HLK4U2ITRZH3KLTJKXCJANCNFSM4W6VPCUA .
Getting the same error :(
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.
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];
snapshot.docs[0].ref.path.split('/')[1];
[Unhandled promise rejection: TypeError: undefined is not an object (evaluating 'snapshot.docs[0].ref')] also give error after using this code
is there is any solution ??
That would only mean that you aren't actually retrieving any files, since it would be undefined. I think this issue is effectively closed - the project would need a patch to make this more standard and integrated.
well i got the answer from the internet you can check it out form stackoverflow πππππ https://stackoverflow.com/a/68456060/14078264
not sure what you mean: I posted that same code above and you claimed it gave you errors and you then also posted it on SO?
well you are right but this code snapshot.docs[0].ref.path.split('/')[1];
is not working for me without this
change
dispatch(fetchUserFollowingPosts(user.id))
to
dispatch(fetchUserFollowingPosts(user.uid))
that's why i post this
that's because there is no such thing as 'id' on the user.
yes that's right
Mine was snapshot.query._.C_.path.segments[1]
, definitely need to log snapshot and look for yourself.
Hi guys, while implementing this practice app, I also came across the section in code where we needed to extract the specific uid for each query by using 'const uid = snapshot.query.EP.path.segments[1]'. I however found that unnecessary, as closure in javascipt binds inner functions to outer functions lexical scope, ensuring they have access to parent function variables. Hence, referencing the uid variable means that we will always get the correct reference. Please read more about it in the attached link, I am open to corrections if I am getting it wrong, thanks. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures
well you are right but this code
snapshot.docs[0].ref.path.split('/')[1];
is not working for me without this changedispatch(fetchUserFollowingPosts(user.id))
todispatch(fetchUserFollowingPosts(user.uid))
Please where did you make the change as I don't seem to find this dispatch(fetchUserFollowingPosts(user.id))
line in my code, on;y dispatch(fetchUsersFollowingPosts(uid))
in the fetchUsersData function.
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];
Yeah, did this and it worked