No video

How to set up React with Firebase/Firestore v9 (Part 1 | onSnapshot)

  Рет қаралды 56,571

RavenJS

RavenJS

2 жыл бұрын

Performing queries in Firestore and deleting documents
Learn how to set up Firestore with React in a CRUD application (Web version 9 - Modular Syntax)
We'll be making a simple full-stack color palette app for this demonstration.
React Firestore v9 Playlist:
• How to set up React wi...
Part 1: Read realtime data with onSnapshot
• How to set up React wi...
Part 2: Create new documents with addDoc/setDoc
• How to set up React wi...
Part 3: Update existing documents with setDoc
• How to set up React wi...
Part 4: Performing queries and deleting documents
• How to set up React wi...
Part 5: Order document query by date created/modified timestamp
• How to set up React wi...
The code used in this video:
github.com/Log...
Firestore Quickstart Documentation:
firebase.googl...

Пікірлер: 198
@sinki3322
@sinki3322 Ай бұрын
I don't even know where to start to thank you. You have just unstuck me from the problem I was trying to fix for the past weeks without receiving any help. You have just allowed me to pass my final exam I've been struggling on so much, and finish my studies. You have just allowed me to get my diploma and start looking for a job. I will never be able to thank you enough. Crazy how people accross the world can literally change your life. Thank you for explaning so well, taking the time and walking us through this. Thank you!
@user-pe8wq3xf1l
@user-pe8wq3xf1l Жыл бұрын
Thanks for the guide! The documentation is less clear. Very helpful, keep up the good work!
@colindaniels1866
@colindaniels1866 Жыл бұрын
holy shit i finally found the blessed video with the info that actually works
@BillyLegumbres
@BillyLegumbres 9 ай бұрын
dude, I can't thank you enough for the clear, concise and helpful tips you gave us to tackle this task you're my hero for reels
@henrydj3220
@henrydj3220 2 жыл бұрын
finally THE SOLUTION. the switch to v9 modular is horrible if you're a beginner coder, this video finally helped me where dozens of stack overflow questions couldn't! thank you!!!!!
@ravenjs
@ravenjs 2 жыл бұрын
exactly @Henry there arent a lot of resources out there for the updated web v9 (modular) right?? hahaa :))
@nomanraihan6035
@nomanraihan6035 2 жыл бұрын
I am not going to forget you in my entire life. If any of your tutorial is not related still I shall watch for the sake of your benefit. I am struggling for many months to understand firebase. Finally I have ended my search. Please make more videos on firebase and react (Project based). Thanks a lot from the bottom of my heart dear brother.
@ravenjs
@ravenjs 2 жыл бұрын
hi Norman, thank you so much for this message. this is exactly the reason that keeps me going! i'm glad that you found this video helpful and than you once again for this amazing comment.
@MrDuff158
@MrDuff158 Жыл бұрын
Been stuck following different tutorials trying to find a way to render the data on screen. Been going around in circles trying to save the data into a variable without using useEffect or useState. You pulled me out of a deep dark hole. Thanks for the excellent tutorial!
@michaelapowers3875
@michaelapowers3875 2 жыл бұрын
Okay, I kid you not, I have been trying to understand how to use Firebase with React-Redux for over two weeks now, and this is the only tutorial that has made enough sense for me to be able to get it to work. Bless you!!!
@ravenjs
@ravenjs 2 жыл бұрын
thank you so much :))
@lrajoo11
@lrajoo11 2 жыл бұрын
This is amazing, and it's the only up to date firebase tutorial I've seen. Subscribed!
@ravenjs
@ravenjs 2 жыл бұрын
thanks Lloyd you're amazing too xD
@te_comp_a_61rahul_pal70
@te_comp_a_61rahul_pal70 2 жыл бұрын
I agree.. I wish his videos come up first because I was struggling with some errors as I was following a 2020 tutorial.. this updated video is really helpful!!
@ravenjs
@ravenjs 2 жыл бұрын
@@te_comp_a_61rahul_pal70 thank you so much HAha i appreciate it!
@ajayraho
@ajayraho 2 жыл бұрын
Totally agreed! And subscribed !
@ravenjs
@ravenjs 2 жыл бұрын
@@ajayraho :)) thanks a million
@oluwaseunrobert7066
@oluwaseunrobert7066 2 жыл бұрын
I love you brother, you just helped me solve my bug, my posts are loading into the document without me reloading, thanks a lot
@abelkibebe577
@abelkibebe577 2 жыл бұрын
Finally, dude u have no idea how much i suffered looking for the firebase video that would work,,, thanks u saved me a lot of time.. keep going We Love U :)
@muhammademirsyah8037
@muhammademirsyah8037 2 жыл бұрын
really help me, been struggling like 5+ hours. found this really help me to solved my problem
@ravenjs
@ravenjs 2 жыл бұрын
this is amazing haha :))
@BrianJackson-zw7jx
@BrianJackson-zw7jx Жыл бұрын
Excellent video talking about snapshots in firebase v9. This is the only video and material that I found that shows how to cleanly unsubscribe on component dismount. Well done and thank you.
@hexd7439
@hexd7439 2 жыл бұрын
That's awesome. Thank you very much. I had been fixing this problem for about an hour then your video saved me. I really appreciate your help.
@KarakiriCAE
@KarakiriCAE 2 жыл бұрын
what a legendary video. all the other videos are outdated or out of scope. you did it man!!!!
@unknownguy2905
@unknownguy2905 Жыл бұрын
Finally a nice firebase video for newbies
@hamednajand4380
@hamednajand4380 Жыл бұрын
Simple. efficient and complete tiny course about firebase!
@learnwithjoe8117
@learnwithjoe8117 2 жыл бұрын
Congratulations on such an awesome, helpful and clear tutorial! I was just about to give up trying to search for a proper firebase firestore v9 tutorial after watching an iMessage clone video which was created using v8 and it no longer works after the update. What I love about your video is you explain details about firestore in plain and simple language which is easily overlooked at by other video tutorials. Now I understand the reason behind the syntax used! I got excited again about learning how to use firestore!!! It seems you have a lot of knowledge about the other uses of firebase so I think it would be amazing if you can give a walk through and also use cases of how to use them. More power and all the best for your channel. P.S. looking forward to your next upload!
@ravenjs
@ravenjs 2 жыл бұрын
Hey @Learn with Joe, thank you so much for this message!! It's always so motivational to read comments like these. also I'm glad that you found this helpful, I wasn't really sure how helpful this was gonna be xD About the other firebase services, I'm in the process of making a video/series about Firebase Authentication, I've been quite busy lately so hopefully I can get it done by this week.. thanks for your support once again :)
@Hiatuz4
@Hiatuz4 2 жыл бұрын
You.... I love you.. you explained everything. Makes so much sense. God blessed you.
@ravenjs
@ravenjs 2 жыл бұрын
thank you haha
@TrixyJ
@TrixyJ 2 жыл бұрын
This is very useful, I wanted to build a note app with firebase and I didn't know how to connect it. It's a great way to learn firebase through this video.
@ravenjs
@ravenjs 2 жыл бұрын
Thanks Jane :))
@tseveendorjganbaatar8958
@tseveendorjganbaatar8958 2 жыл бұрын
This is exactly what I just need so far. thank you
@tomasgilamoedo8301
@tomasgilamoedo8301 2 жыл бұрын
Clearly the best firebase &React tutorial on KZbin! congratz bro & its really appreciated
@ravenjs
@ravenjs 2 жыл бұрын
Haha thanks bro tqsm :))
@theonewhowill4903
@theonewhowill4903 2 жыл бұрын
Thank you so much, the official documentation wasn't much help. I'm glad I found this.
@gregzc9395
@gregzc9395 Жыл бұрын
Great videos really helpful I'm just finished a programming course and I'm trying to learn firebase right now and these videos are really helpful!
@hojinharry6270
@hojinharry6270 Жыл бұрын
You are a lifesavor. thank you for your videos. keep it up.
@delta.v9912
@delta.v9912 2 жыл бұрын
Thank you for the video! I am so happy I found this, you explain everything very well, in the end it just feels so simple, can't wait to watch the next episodes. :)
@ravenjs
@ravenjs 2 жыл бұрын
thanks @Tomasz :))
@vegardlokreim5549
@vegardlokreim5549 8 ай бұрын
first comment on youtube ( in like 5 years) Great work! Thanks a lot! You deserve more subscribers! Also...Your way of describing/explaining is well structured (imo)! keep up the good work!
@bolajioyewo1515
@bolajioyewo1515 2 жыл бұрын
Wow, You just made my day with this video. Thanks man
@ravenjs
@ravenjs 2 жыл бұрын
and you just made my day with this comment. Thank you :)
@VIETNGUYEN-gb7gn
@VIETNGUYEN-gb7gn 2 жыл бұрын
thanks for your guide, i have looked up this for a time
@DonDaMoniker
@DonDaMoniker 2 жыл бұрын
Succinct and easily transferable to other uses. Thank you.
@ollyoctavian
@ollyoctavian Жыл бұрын
Really nice videos! Keep up the good work and you will go far.
@arkindustries7347
@arkindustries7347 2 жыл бұрын
Thanks dude, It help a lot learning new firebase sdk. Excited to part 2!
@ravenjs
@ravenjs 2 жыл бұрын
Haha I'm excited for part 2 too!
@amrmahmoud3082
@amrmahmoud3082 2 жыл бұрын
Thanks Thanks i have been struggle from this and you made it so simple thank you very much ❤❤❤❤❤❤
@ravenjs
@ravenjs 2 жыл бұрын
@AmrMahmoud thank you :)))
2 жыл бұрын
Hi, thanks for the video. You helped me to figure out the combination useEffect and Snapshot.👏 The Firebase docs are kind of clumky. So I also want to share knowledge with you. Inside of the useEffect you were doing something like "return unsub". The correct way is: "return ( ) => unsub( )" In short it needs to return a function which calls back (pun intended) unsub. 😊
@mamunmahmood8070
@mamunmahmood8070 2 жыл бұрын
Thanks, man I was stuck with this modular version.
@64revolt
@64revolt 3 ай бұрын
To make the consol logs bigger (on brave at the least), open the dev-tools and then zoom using ctrl+ :) Also, awesome tutorial :D
@riyabhandari2795
@riyabhandari2795 2 жыл бұрын
Wow , what a perfect explanation, totally NOTEWORTHY Video for firestore no doubt 😄💯💯🙌🏻
@ravenjs
@ravenjs 2 жыл бұрын
Haha thank you so much @Riya
@priyankaroberts1093
@priyankaroberts1093 Жыл бұрын
Hey Riya ! Have you built any projects in React? Are you looking out for any job opportunities in React or other JS frameworks currently?
@riyabhandari2795
@riyabhandari2795 Жыл бұрын
@@priyankaroberts1093 yes I'm open for job opportunities
@priyankaroberts1093
@priyankaroberts1093 Жыл бұрын
@@riyabhandari2795 awesome. Connect with me using my profile link given on my channel so that we can continue this conversation there?
@riyabhandari2795
@riyabhandari2795 Жыл бұрын
@@priyankaroberts1093 okay 👍
@Enigmata23
@Enigmata23 2 жыл бұрын
Thank you for this. Subscribed.
@ritualj0int
@ritualj0int 2 жыл бұрын
Proper job mate, was really helpful for me!
@sebastiangarzonarias9193
@sebastiangarzonarias9193 2 жыл бұрын
Thank you, you helped me with the video to finally solve a problem I had with a project of mine.
@ravenjs
@ravenjs 2 жыл бұрын
awesome :)))
@ahmedhossam475
@ahmedhossam475 2 жыл бұрын
Man thanks for this video! I didn't understand how it works from the official documentation.
@ravenjs
@ravenjs 2 жыл бұрын
you're most welcome! glad i could help
@heyiamigor
@heyiamigor 2 жыл бұрын
Amazing work. Keep it up!
@ravenjs
@ravenjs 2 жыл бұрын
thank you so much Igor
@Son-vy5rl
@Son-vy5rl 2 жыл бұрын
This was great, I really needed to know how to add the id into the doc.data() object. Thank you!
@KodyWright-od2tb
@KodyWright-od2tb 5 ай бұрын
You are a game changer!
@jain78343
@jain78343 2 жыл бұрын
very very very Useful!!!!!! Thank you so much
@chrisnotthere
@chrisnotthere 2 жыл бұрын
You have a great way of explaining why and what you are doing. Thank you for this great content! Subscribed!
@ravenjs
@ravenjs 2 жыл бұрын
Awesome, thank you! @Chris I appreciate it :))
@Rolfikv
@Rolfikv 2 жыл бұрын
Dude... Thanks! amazing tutorial.
@ravenjs
@ravenjs 2 жыл бұрын
thank you :))
@uwagideon2723
@uwagideon2723 2 жыл бұрын
bro you're the best
@shivangkhandelwal334
@shivangkhandelwal334 2 жыл бұрын
Thank you thank you thank you, all my problem is solved in 15 minutes 🤩🤩🤩
@priyankaroberts1093
@priyankaroberts1093 Жыл бұрын
Hey Shivang Have you worked with react lately ? Would you be interested in exploring internship/job opportunities in web development ?
@user-ib7ux3js1n
@user-ib7ux3js1n Жыл бұрын
Amazing video, thanks!
@OtisDeLarge
@OtisDeLarge 2 жыл бұрын
Btw you can make the dev tools larger by pressing CTRL and "+" while it's in focus. Thanks for the tutorial.
@ravenjs
@ravenjs 2 жыл бұрын
thanks for the tip Jim!! Idk why I couldn't figure it out earlier heh
@oguzhanseker6806
@oguzhanseker6806 2 жыл бұрын
Keep up the work brother. Appreciated. :)
@ravenjs
@ravenjs 2 жыл бұрын
Thank you :))))
@te_comp_a_61rahul_pal70
@te_comp_a_61rahul_pal70 2 жыл бұрын
You are amazing!! Keep up the good work!!❤️❤️
@ravenjs
@ravenjs 2 жыл бұрын
You're amazing too! :))
@mubashirwaheed474
@mubashirwaheed474 2 жыл бұрын
Thank you so much for this video
@ravenjs
@ravenjs 2 жыл бұрын
Most welcome 😊
@discontinuity
@discontinuity Жыл бұрын
So helpful thanks
@JaydenLOL
@JaydenLOL 2 жыл бұрын
So underrated! Do more tutorials!
@ravenjs
@ravenjs 2 жыл бұрын
I will @Jayden!!! Thank you so much
@dalandanemaas3241
@dalandanemaas3241 9 ай бұрын
This is helpfull. thanks!
@TheYoterompo
@TheYoterompo Жыл бұрын
Thanks dude, you actually help me a lot!!!
@codeyourdreams5894
@codeyourdreams5894 2 жыл бұрын
nice
@ravenjs
@ravenjs 2 жыл бұрын
Thanks bro 😌
@MAXBOU0215
@MAXBOU0215 2 жыл бұрын
You saved my life
@javierperez_com
@javierperez_com 2 жыл бұрын
Really good tutorial. Thank you so much.
@ravenjs
@ravenjs 2 жыл бұрын
Thanks Javier !!😙
@barsarbro4610
@barsarbro4610 2 жыл бұрын
Press control and + button for increase size of console window
@ravenjs
@ravenjs 2 жыл бұрын
@parag barsar thank you so much ! ha i tried it and it works!!! how did i not know of this sooner...
@axelpo9390
@axelpo9390 2 жыл бұрын
very thanks !!!!
@ravenjs
@ravenjs 2 жыл бұрын
awesome :))
@JavierSosa
@JavierSosa 2 жыл бұрын
Thank you so much dude! Greate work!
@ravenjs
@ravenjs 2 жыл бұрын
thx for the encouragement Javier :))
@mcdaddy1334
@mcdaddy1334 2 жыл бұрын
VERY NICE!
@ravenjs
@ravenjs 2 жыл бұрын
THANK YOU :)
@conorkelly6391
@conorkelly6391 2 жыл бұрын
Brilliant first video. I have what I expected with a js component. Only tried that as my typescript component wasn't working. property name is missing in type {'id: string'} . Any ideas?
@pawntozy
@pawntozy 2 жыл бұрын
I almost cried when this worked for me
@ravenjs
@ravenjs 2 жыл бұрын
i know that feeling :))
@reactteamwdp7648
@reactteamwdp7648 2 жыл бұрын
thank you so much sir
@ene_andre
@ene_andre 2 жыл бұрын
Thank you so much
@nejan_s
@nejan_s 2 жыл бұрын
thanks a lot :)
@ravenjs
@ravenjs 2 жыл бұрын
you're most welcome 😁
@chotaHatti
@chotaHatti 2 жыл бұрын
Thank you so much.
@priyankaroberts1093
@priyankaroberts1093 Жыл бұрын
Hey Pranav Have you worked on any react projects recently ? Are you open to any opportunities in software development ?
@iankitverma
@iankitverma 2 жыл бұрын
Awesome. Can you please make a video on how to authenticate user with phone number and store the details of user on firestore, it be great ! Thanks.
@ravenjs
@ravenjs 2 жыл бұрын
thanks @Ankit! this is an amazing suggestion. I'll definitely be looking to add this to the Firebase Auth playlist
@priyankaroberts1093
@priyankaroberts1093 Жыл бұрын
Hey Ankit Are you working on react projects presently? Are you interested in exploring opportunities in web development ?
@azizanbouri4101
@azizanbouri4101 Жыл бұрын
god bless you brother
@arslanahmed1311
@arslanahmed1311 Жыл бұрын
Thanks
@dr.lunyak2386
@dr.lunyak2386 2 жыл бұрын
парень, ты очень крутой! спасибо!
@IvanClayMoura
@IvanClayMoura 2 жыл бұрын
Thank you for this video tutorial. Can you make a video about social login with version 9 of firebase?
@ravenjs
@ravenjs 2 жыл бұрын
Yes @Ivan I'll be doing a new series for Firebase Auth :)) thx for the suggestion too
@rroossyyiidd
@rroossyyiidd 2 жыл бұрын
Thanks a lot :)
@ravenjs
@ravenjs 2 жыл бұрын
thank you :))
@m__link6499
@m__link6499 2 жыл бұрын
Nice video...I think the function is called getDocs and not getData (12:47)....
@ravenjs
@ravenjs 2 жыл бұрын
yes, i think you're right :)) thx for the correction
@WillSmith-qt7me
@WillSmith-qt7me 2 жыл бұрын
More React and Firebase 9 tutorials, Tailwind. Thanks.
@ravenjs
@ravenjs 2 жыл бұрын
Ah Tailwind CSS. yes yes Will thanks for the suggestion!
@MadaraUchiha_404
@MadaraUchiha_404 2 жыл бұрын
thanks a lot
@olivergjesing1721
@olivergjesing1721 Жыл бұрын
My man
@rafaelsoteldosilva
@rafaelsoteldosilva 2 жыл бұрын
Hi!. Thank you for these great lessons. They have been really useful. I have a question; Could you explain to me why the use of onSnapshot in useEffect like 'useEffect(() => onSnapshot...' assures that the listener will be terminated whenever the user is done. I was researching the internet and they use unsub but the app stops showing the data, under your approach it shows the data. I'm concerned about having it developed in React Native to have the users have the app, but it could deplete the battery if it's not properly done. Thanks in advance for your answer
@ravenjs
@ravenjs Жыл бұрын
In ES6 syntax, when you make an arrow function like this: () => someFunction() the return value of when someFunction is executed will be automatically returned to the parent arrow function. React's useEffect hook is designed to automatically execute any function handles that are returned to it. In this case, we are returning the return value of onSnapshot (which is the unsub function) to useEffect.
@mohammadpiramun5913
@mohammadpiramun5913 2 жыл бұрын
thanks for this video and i hoop that you make more of that video in the future with some real react app thank bro.....
@ravenjs
@ravenjs 2 жыл бұрын
thank u too mohammad :)))
@aramabdulrahman2087
@aramabdulrahman2087 2 жыл бұрын
please depending on cost which one better realtime db or cloud firestore db for datatable with more search request per month thanks....
@ravenjs
@ravenjs 2 жыл бұрын
realtime db's costing depends on the storage size of your data, whereas cloud firestore's costing depends on the number of operations that you perform. In cloud firestore, the size of your data doesn't really matter because it's the number of operations that costs you money :)
@joaopaulo-ff3vb
@joaopaulo-ff3vb 2 жыл бұрын
thanks bro
@thaibinh6585
@thaibinh6585 2 жыл бұрын
hi I am using react native by expo and when try to const db = getFirestore() or console.log(getFireStore()) its said "undefined is not an object (evaluating '_ref23.options')". Do you know how to solve this problem? I've tried to search for it but cannot find the answer
@ravenjs
@ravenjs 2 жыл бұрын
hmm did you check if your API key is correct? if it is and it still doesn't work, you could try using the v8 (namespaced) syntax and see if that gives you the same error too?
@thaibinh6585
@thaibinh6585 2 жыл бұрын
@@ravenjs I researched more and find out that firebase v9 is not compatible with expo so I return to v8 and it works fine
@ravenjs
@ravenjs 2 жыл бұрын
@@thaibinh6585 ahh so the issue is indeed because of v9.. I was just taking a wild guess because I’ve never tried Firebase with expo too 🙃 Thanks for letting me know @Thai Binh I’ll be looking out for similar errors in the future :))
@thaibinh6585
@thaibinh6585 2 жыл бұрын
@@ravenjs man its took me 2-3 days trying over and over until I frustrated and happens to find the answer, feel bad man
@jessepinkman5649
@jessepinkman5649 2 жыл бұрын
Thank you sir
@ravenjs
@ravenjs 2 жыл бұрын
awesome @Jesse :))
@137dylan
@137dylan 2 жыл бұрын
Hi..before I watch, can you please tell me: 1. Is this using the latest version of Firebase 2. Do you include usage of the firebase hooks package 3. How many parts will there be to the series and when will they all be out Thanks!
@ravenjs
@ravenjs 2 жыл бұрын
1. Yes I used the latest version of Firebase with the latest syntax (modular ES6) 2. No, I'm not using the 'react-firebase-hooks' package if that's what you're asking, but a video on how to create our own custom Firestore hooks is coming up! 3. There are only 2 parts to the series at the moment, coming out within the week. If more ideas come, I might add additional videos to the series but all of the basics would already be contained in the first two parts.
@IanMont
@IanMont 2 жыл бұрын
Please please could you make a tutorial on Firebase Auth with login with profile picture and using the latest version of firebase(v9 modular) PLEASE BROO
@ravenjs
@ravenjs 2 жыл бұрын
Hahaah @Ian Mont good suggestion, I'll get to it ASAP
@IanMont
@IanMont 2 жыл бұрын
@@ravenjs Yeaaahh
@wiazowski1
@wiazowski1 Жыл бұрын
The problem with most tutorials is that people explain what they are doing with the objects and functions, but they dont explain what exactly the functions or objects are doing, neither the origen of thoses and why we need them.
@richardbee_r
@richardbee_r Жыл бұрын
Bro Thank you so much With this video, I was finally able to unsubscribe my listeners Thank you
@TheNamesJT
@TheNamesJT 2 жыл бұрын
So, in my collection i have a map defined on the cloud firestore. However, it won't display the values. which is weird. Because the collection is the collection used in useEffect so it should not be undefined because it has a value. I'm getting this error TypeError: can't convert undefined to object. On firebase docs it says "Map: By keys, then by value -Represents an object embedded within a document. When indexed, you can query on subfields. If you exclude this value from indexing, then all subfields are also excluded from indexing." {Object.entries(users.identity).map((key, value) => ( {value.firstName} {value.lastName} ))}
@ravenjs
@ravenjs 2 жыл бұрын
Is your source code huge? Could you upload your file to pastebin (excluding sensitive information/API Keys) and post the link here? And could you also paste the link to the Firebase docs that you referenced? Thx @TheNamesJT :))
@TheNamesJT
@TheNamesJT 2 жыл бұрын
@@ravenjs Thanks but decided not to use firebase just wasn't working moved onto mongodb and going to deploy to heroku once i'm done with creating the database using that. Firebase is blah...
@ravenjs
@ravenjs 2 жыл бұрын
@@TheNamesJT Haha yes sometimes MongoDB is just better suited than Firebase :)))
@puneetdhiman5194
@puneetdhiman5194 2 жыл бұрын
The component is re rendering continuously.
@ravenjs
@ravenjs 2 жыл бұрын
Did you add the empty array as the second argument for useEffect?
@puneetdhiman5194
@puneetdhiman5194 2 жыл бұрын
@@ravenjs yes
@ravenjs
@ravenjs 2 жыл бұрын
@@puneetdhiman5194 you could put your code on pastebin if you want me to check it out :))
@priyankaroberts1093
@priyankaroberts1093 Жыл бұрын
Hey Puneet Good to know that you like learning from these tutorials. Are you a fresher and open to exploring opportunities in web development currently?
@puneetdhiman5194
@puneetdhiman5194 Жыл бұрын
@@priyankaroberts1093 yes
@100028237
@100028237 2 жыл бұрын
can we put another snapshot in the root snapshot with async/await?
@ravenjs
@ravenjs 2 жыл бұрын
what do you mean?
@100028237
@100028237 2 жыл бұрын
@@ravenjs for outer snap , i want to get the list of documents . For inner snap , i want to get doc by id from the list of ducments.
@kushalshukla444
@kushalshukla444 2 жыл бұрын
thanks dude , btw what i was doing is like importing firebase from "firebase" but it showing error , `firebase is not imported like that` :(
@ravenjs
@ravenjs 2 жыл бұрын
did you manage to fix the error @kushal?
@kushalshukla444
@kushalshukla444 2 жыл бұрын
@@ravenjs yep
@ravenjs
@ravenjs 2 жыл бұрын
@@kushalshukla444 could you paste the full error here if you want me to take a look it it ? :))
@kushalshukla444
@kushalshukla444 2 жыл бұрын
@@ravenjs console.log("first") useEffect(() => onSnapshot(collection(db,"message"),(snap)=>{ SetMessages(snap.docs.map(doc=>doc.data())) }, [])); here what is happening is that when this code run, it keep on printing "first" , SetMessages is a function of usestate array.
@ravenjs
@ravenjs 2 жыл бұрын
@@kushalshukla444 it seems like your React App is perpetually re-rendering for some reason. Could it be because of some code snippet that you wrote outside of useEffect()? another possible reason is because you forgot to put in the empty array as the 2nd argument in useEffect, but I think you already have it in the snippet that you pasted here useEffect( () => {}, [] )
@Atlantis281
@Atlantis281 2 жыл бұрын
Hi. This vid helped me out greatly in my current project! Question: How would I go about limiting the onSnapshot to only bring over 2 docs? I see on Firebase I need to use limit(2) but I cant see where I need to put that in this code. Any help would be awesome!
@ravenjs
@ravenjs 2 жыл бұрын
Hello. First, you'd wanna do the imports: import { query, collection, limit, onSnapshot } from "firebase/firestore"; Then, use limit(2) like so: const collectionRef = collection(db, 'collectionName'); // Get the collection's reference const q = query(collectionRef, limit(3)); // Store the query in variable 'q' Then, replace the first argument of onSnapshot with the query variable 'q': const unsub = onSnapshot(q, (doc) => { // ... }); Let me know if this works! I have yet to try this myself too.
@Atlantis281
@Atlantis281 2 жыл бұрын
@@ravenjs Worked with some modifications. const [blogs, setBlogs] = useState([]); const collectionRef = collection(db, "blogs"); const q = query(collectionRef, limit(2)); useEffect( () => onSnapshot(q,(snapshot) => setBlogs(snapshot.docs.map((doc) => ({...doc.data(), id: doc.id}))) ), [q] );
@ravenjs
@ravenjs 2 жыл бұрын
@@Atlantis281 Awesome amazing! :))
@rubenverster250
@rubenverster250 2 жыл бұрын
JUST GO RTFM! ༼ つ ◕_◕ ༽つ
@ravenjs
@ravenjs 2 жыл бұрын
hahaah :))
@Better_Dev
@Better_Dev 2 жыл бұрын
How do I push data to FireStore with a unique id?
@ravenjs
@ravenjs 2 жыл бұрын
Hey! What you wanted to do is gonna be in Part 2, but since you're here early I'll just show u how to do it now :)))) So this is what you'd do in an async function: const docRef = await addDoc(collection(db, "colors"), { name: "White", value: "#fff" }); console.log("Document written with ID: ", docRef.id); If you prefer promises: addDoc(collection(db, "colors"), { name: "White", value: "#fff" }).then(docRef => console.log("Document written with ID: ", docRef.id)); You don't have to specific an ID if you want Firestore to automatically generate one for you. Also, don't forget the imports: import { collection, addDoc } from "firebase/firestore";
@Better_Dev
@Better_Dev 2 жыл бұрын
@@ravenjs I'm using a promise, changed my setDoc to add Doc. const sendPost = e => { addDoc(doc(db, 'posts'),{ name: "Connor", description: "Developer", message: input, }).then(DocumentReference => console.log("Document written with ID: ", **What goes here)); I'm getting an error saying my document ref must have an even number or segments, but posts has 1. Appreciate the help!
@ravenjs
@ravenjs 2 жыл бұрын
@@Better_Dev nice. Did it work?
@Better_Dev
@Better_Dev 2 жыл бұрын
@@ravenjs No im getting an error saying my "document ref must have an even number of segments, but posts has 1" Struggling here
@ravenjs
@ravenjs 2 жыл бұрын
@@Better_Dev ​ First, "**What goes here" should be DocumentReference.id in your case, but this console.log is totally optional. Next, the reason why you're getting the document ref error is because you are using doc(db, 'posts') as the first argument in addDoc(). doc() targets a specific document, whereas collection() targets an entire collection. In your case, you probably should target a collection because you are adding a document to a collection. So, simply changing doc(db, 'posts') to collection(db, 'posts') would work.
@abdelhalim731
@abdelhalim731 2 жыл бұрын
gj
@ravenjs
@ravenjs 2 жыл бұрын
thanks :)
@fouziarief
@fouziarief 2 жыл бұрын
hi its great firebase tutorial am trying to work on am getting this error can please help on this "errors.ts:94 Uncaught FirebaseError: Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore"
@ravenjs
@ravenjs 2 жыл бұрын
you might have to check the path of your document/collection reference
Pool Bed Prank By My Grandpa 😂 #funny
00:47
SKITS
Рет қаралды 18 МЛН
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 153 МЛН
天使救了路飞!#天使#小丑#路飞#家庭
00:35
家庭搞笑日记
Рет қаралды 59 МЛН
I built a chat app in 7 minutes with React & Firebase
8:53
Fireship
Рет қаралды 1,4 МЛН
Top 10 CSS One Liners That Will Blow Your Mind
13:34
developedbyed
Рет қаралды 938 М.
The Story of Next.js
12:13
uidotdev
Рет қаралды 563 М.
React Firebase Tutorial | AUTH - CRUD - Image Upload
1:27:43
Lama Dev
Рет қаралды 209 М.
Build APIs with Flask (the right way)
49:09
microapis
Рет қаралды 9 М.
Firebase - Back to the Basics
25:23
Fireship
Рет қаралды 587 М.
Pool Bed Prank By My Grandpa 😂 #funny
00:47
SKITS
Рет қаралды 18 МЛН