Comments (27)
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]
from instagramclone.
well i got the answer from the internet you can check it out form stackoverflow
πππππ
https://stackoverflow.com/a/68456060/14078264
from instagramclone.
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.
from instagramclone.
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];
from instagramclone.
that's because there is no such thing as 'id' on the user.
from instagramclone.
just figured out this is a repost of #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
from instagramclone.
Have you found any solutions?
from instagramclone.
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
from instagramclone.
Guys have you solved this??
from instagramclone.
it gives an error friend
@digimbyte
from instagramclone.
i have the same problem
from instagramclone.
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.
from instagramclone.
from instagramclone.
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/
from instagramclone.
from instagramclone.
Getting the same error :(
from instagramclone.
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
from instagramclone.
is there is any solution ??
from instagramclone.
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.
from instagramclone.
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?
from instagramclone.
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))
from instagramclone.
that's why i post this
from instagramclone.
yes that's right
from instagramclone.
Mine was snapshot.query._.C_.path.segments[1]
, definitely need to log snapshot and look for yourself.
from instagramclone.
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
from instagramclone.
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.
from instagramclone.
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
from instagramclone.
Related Issues (20)
- I can't seem to load comments with username attached
- snapshot.ZE.path.segments is undefined HOT 1
- updateUserFeedPosts is not defined in Redux actions HOT 1
- ReferenceError: Can't find variable: initialState
- Setup-your-project - need exact versions to install to avoid errors HOT 3
- 903433436 HOT 1
- When following the wiki to deploy section e In the indexes tab create the following index: is left blank.
- Has anyone succeeded adding drawer navigation to profile screen?
- Section (e) of wiki "In the indexes tab create the following index: " is left blank.
- Bl
- npm install expo - can't start project? HOT 2
- https://github.com/SimCoderYoutube/InstagramClone.wiki.git
- The error you're experiencing is a dependency resolution problem in npm
- Instagram hack HOT 1
- Clone instagram HOT 1
- const found = getState().usersState.users.some(el => el.uid === uid) HOT 1
- Inka
- Issue when fetching Feed from following
- Issue getting uid using getState from redux
- A
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from instagramclone.