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!
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!!!!!
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!!!
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!
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 :)
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!!
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.
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!
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 :)
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.
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!
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. :)
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. 😊
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
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 :)
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?
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
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.
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
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 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 :))
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!
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.
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} ))}
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 :))
@@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...
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!
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.
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.
@@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.
@@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( () => {}, [] )
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?
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";
@@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!
@@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.
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"
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!
holy shit i finally found the blessed video with the info that actually works
Thanks for the guide! The documentation is less clear. Very helpful, keep up the good work!
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!!!!!
exactly @Henry there arent a lot of resources out there for the updated web v9 (modular) right?? hahaa :))
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!!!
thank you so much :))
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!
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
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 :)
I love you brother, you just helped me solve my bug, my posts are loading into the document without me reloading, thanks a lot
This is amazing, and it's the only up to date firebase tutorial I've seen. Subscribed!
thanks Lloyd you're amazing too xD
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!!
@@te_comp_a_61rahul_pal70 thank you so much HAha i appreciate it!
Totally agreed! And subscribed !
@@ajayraho :)) thanks a million
really help me, been struggling like 5+ hours. found this really help me to solved my problem
this is amazing haha :))
Finally a nice firebase video for newbies
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.
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.
what a legendary video. all the other videos are outdated or out of scope. you did it man!!!!
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!
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 :)
You are a lifesavor. thank you for your videos. keep it up.
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.
Thanks Jane :))
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!
Clearly the best firebase &React tutorial on TH-cam! congratz bro & its really appreciated
Haha thanks bro tqsm :))
Simple. efficient and complete tiny course about firebase!
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!
This is exactly what I just need so far. thank you
You.... I love you.. you explained everything. Makes so much sense. God blessed you.
thank you haha
Wow , what a perfect explanation, totally NOTEWORTHY Video for firestore no doubt 😄💯💯🙌🏻
Haha thank you so much @Riya
Hey Riya ! Have you built any projects in React? Are you looking out for any job opportunities in React or other JS frameworks currently?
@@priyankaroberts1093 yes I'm open for job opportunities
@@riyabhandari2795 awesome. Connect with me using my profile link given on my channel so that we can continue this conversation there?
@@priyankaroberts1093 okay 👍
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. :)
thanks @Tomasz :))
Man thanks for this video!
I didn't understand how it works from the official documentation.
you're most welcome! glad i could help
Thank you so much, the official documentation wasn't much help. I'm glad I found this.
Thanks dude, It help a lot learning new firebase sdk. Excited to part 2!
Haha I'm excited for part 2 too!
thanks for your guide, i have looked up this for a time
Amazing video, thanks!
Thank you for this. Subscribed.
Wow, You just made my day with this video. Thanks man
and you just made my day with this comment. Thank you :)
You are a game changer!
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. 😊
Really nice videos! Keep up the good work and you will go far.
Thanks, man I was stuck with this modular version.
Thank you thank you thank you, all my problem is solved in 15 minutes 🤩🤩🤩
Hey Shivang
Have you worked with react lately ? Would you be interested in exploring internship/job opportunities in web development ?
This was great, I really needed to know how to add the id into the doc.data() object. Thank you!
Thank you, you helped me with the video to finally solve a problem I had with a project of mine.
awesome :)))
Btw you can make the dev tools larger by pressing CTRL and "+" while it's in focus. Thanks for the tutorial.
thanks for the tip Jim!! Idk why I couldn't figure it out earlier heh
Nice video...I think the function is called getDocs and not getData (12:47)....
yes, i think you're right :)) thx for the correction
Proper job mate, was really helpful for me!
You have a great way of explaining why and what you are doing. Thank you for this great content!
Subscribed!
Awesome, thank you! @Chris I appreciate it :))
Thanks Thanks i have been struggle from this and you made it so simple thank you very much ❤❤❤❤❤❤
@AmrMahmoud thank you :)))
bro you're the best
Amazing work. Keep it up!
thank you so much Igor
To make the consol logs bigger (on brave at the least), open the dev-tools and then zoom using ctrl+ :)
Also, awesome tutorial :D
Dude... Thanks! amazing tutorial.
thank you :))
This is helpfull. thanks!
very very very Useful!!!!!!
Thank you so much
Thank you so much for this video
Most welcome 😊
You are amazing!! Keep up the good work!!❤️❤️
You're amazing too! :))
So helpful thanks
Press control and + button for increase size of console window
@parag barsar thank you so much ! ha i tried it and it works!!! how did i not know of this sooner...
Succinct and easily transferable to other uses. Thank you.
Keep up the work brother. Appreciated. :)
Thank you :))))
Thanks dude, you actually help me a lot!!!
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
Hahaah @Ian Mont good suggestion, I'll get to it ASAP
@@ravenjs Yeaaahh
please depending on cost which one better realtime db or cloud firestore db for datatable with more search request per month thanks....
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 :)
So underrated! Do more tutorials!
I will @Jayden!!! Thank you so much
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?
You saved my life
god bless you brother
Thank you so much.
Hey Pranav
Have you worked on any react projects recently ? Are you open to any opportunities in software development ?
I almost cried when this worked for me
i know that feeling :))
Really good tutorial. Thank you so much.
Thanks Javier !!😙
thank you so much sir
Thank you for this video tutorial.
Can you make a video about social login with version 9 of firebase?
Yes @Ivan I'll be doing a new series for Firebase Auth :)) thx for the suggestion too
Thank you so much
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
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.
Thanks
Bro
Thank you so much
With this video, I was finally able to unsubscribe my listeners
Thank you
VERY NICE!
THANK YOU :)
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.
thanks @Ankit! this is an amazing suggestion. I'll definitely be looking to add this to the Firebase Auth playlist
Hey Ankit
Are you working on react projects presently? Are you interested in exploring opportunities in web development ?
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
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?
@@ravenjs I researched more and find out that firebase v9 is not compatible with expo so I return to v8 and it works fine
@@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 :))
@@ravenjs man its took me 2-3 days trying over and over until I frustrated and happens to find the answer, feel bad man
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!
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.
can we put another snapshot in the root snapshot with async/await?
what do you mean?
@@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.
Thank you so much dude! Greate work!
thx for the encouragement Javier :))
thanks a lot :)
you're most welcome 😁
парень, ты очень крутой! спасибо!
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}
))}
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 :))
@@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...
@@TheNamesJT Haha yes sometimes MongoDB is just better suited than Firebase :)))
very thanks !!!!
awesome :))
thanks a lot
My man
More React and Firebase 9 tutorials, Tailwind. Thanks.
Ah Tailwind CSS. yes yes Will thanks for the suggestion!
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!
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.
@@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]
);
@@Atlantis281 Awesome amazing! :))
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.
thanks for this video and i hoop that you make more of that video in the future with some real react app
thank bro.....
thank u too mohammad :)))
thanks dude , btw what i was doing is like importing firebase from "firebase" but it showing error , `firebase is not imported like that` :(
did you manage to fix the error @kushal?
@@ravenjs yep
@@kushalshukla444 could you paste the full error here if you want me to take a look it it ? :))
@@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.
@@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( () => {}, [] )
The component is re rendering continuously.
Did you add the empty array as the second argument for useEffect?
@@ravenjs yes
@@puneetdhiman5194 you could put your code on pastebin if you want me to check it out :))
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?
@@priyankaroberts1093 yes
nice
Thanks bro 😌
How do I push data to FireStore with a unique id?
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";
@@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!
@@Better_Dev nice. Did it work?
@@ravenjs No im getting an error saying my "document ref must have an even number of segments, but posts has 1"
Struggling here
@@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.
Thanks a lot :)
thank you :))
Thank you sir
awesome @Jesse :))
thanks bro
JUST GO RTFM! ༼ つ ◕_◕ ༽つ
hahaah :))
gj
thanks :)
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"
you might have to check the path of your document/collection reference