Build a Blog Website - React and Firebase Tutorial

Поділитися
Вставка
  • Опубліковано 12 лис 2024

КОМЕНТАРІ • 258

  • @PedroTechnologies
    @PedroTechnologies  2 роки тому +61

    Hey everyone, I forgot to fix something in the video. In order to prevent infinite reads and in order for the delete to refresh after a post is deleted, you need to change the useffect in the home page to the following:
    useEffect(() => {
    const getPosts = async () => {
    const data = await getDocs(postsCollectionRef);
    setPostList(data.docs.map((doc) => ({ ...doc.data(), id: doc.id })));
    };
    getPosts();
    }, [deletePost]);

    • @talbertherndon1925
      @talbertherndon1925 2 роки тому +3

      Please do more firebase tutorials. This is amazing!

    • @nithinm0836
      @nithinm0836 2 роки тому +4

      I changed the code as you guided. But still it reads infinite times. Actually the problem is with the setPostList(). When you just console log the data
      useEffect(() => {
      const getPosts = async () => {
      const data = await getDocs(postsCollectionRef);
      console.log(data);
      };
      getPosts();
      });
      The data is fetched just once. But when you include setPostList(),
      useEffect(() => {
      const getPosts = async () => {
      const data = await getDocs(postsCollectionRef);
      console.log(data);
      setPostList(data.docs.map((doc) => ({ ...doc.data(), id: doc.id })));
      };
      getPosts();
      });
      it results in a large no of reads.

    • @dmitrisamo5129
      @dmitrisamo5129 2 роки тому +6

      deletePost function needs to be moved above useEffect

    • @nithinm0836
      @nithinm0836 2 роки тому +1

      @@dmitrisamo5129 yeah I moved it. Otherwise it would be an error. Did it work for you dude? Can u share ur code if possible?...

    • @dmitrisamo5129
      @dmitrisamo5129 2 роки тому +2

      @@nithinm0836 Sorry dude, adding the deletePost where Pedro says, refreshes the delete page but keeps looping the database and I've reached my quota in firebase because of that. I am still checking how to have both, refreshing and stop the crazy loop. So, I would recommend everyone to keep the array empty until further solution is found.

  • @SpencerWhiteman
    @SpencerWhiteman 2 роки тому +21

    Literally the best timing ever. I was just trying to figure out how I wanted to build my blog and you came in clutch, thank you so much Pedro!

  • @luispericchi9347
    @luispericchi9347 2 роки тому +8

    I can't thank you enough man, this is a beautifully structured extremely clear tutorial. I hope your channel keeps growing!

  • @erikacontrerasleal2484
    @erikacontrerasleal2484 9 місяців тому +1

    I only watched for 1 min and you have my like, I can't wait to build my blog, thanks a lot!

  • @shinobi_coder88
    @shinobi_coder88 2 роки тому +10

    Have been watching your entire firebase v9 videos. This really helps, although I'm a frontend dev who rarely stores authenticated users data and this is very handy as we don't have to deal with complex backend stuff. Since you have been teaching us about Firebase Firestore and Auth, what about including Firebase Cloud Function and Hosting for the next course? Really appreciate it Pedro ✌️

  • @ankushchavhan1332
    @ankushchavhan1332 2 роки тому +3

    I am very happy that your channel got me too early in my react learning in beginning 🥳

  • @turbofuture1
    @turbofuture1 2 роки тому +3

    literally wanted to build a blog, you came at just the right time :)

  • @johnpaulpineda2476
    @johnpaulpineda2476 2 роки тому +1

    I really love watching Pedro simply because, he's teaching very simple and understandable on a perspective of a beginner. :)

  • @aldolhitlercondensation1363
    @aldolhitlercondensation1363 2 роки тому

    Hey it's me again! I was looking for such a video on youtube and I saw you had one on it. I instantly told my friends that I'd be returning with a basic functioning knowledge of firebase react the next day. you have a way of keeping things short but to the point. I havent started watching the video yet but I know it'll be great! (hopefully no errors xd) but THANKS A TON!

  • @tomasgilamoedo8301
    @tomasgilamoedo8301 2 роки тому

    I was just needing this man, been looking for firebase good content but its really hard tho, Thxz a lot Pedro, really appreciated!

  • @bilbo_gamers6417
    @bilbo_gamers6417 Рік тому

    Thank you so much for making this! I haven't done any CSS to this yet but it looks SO COOL! I'm going to try and make a Kanban board with this. I have been studying backend stuff and object oriented languages for most of the time I've been studying CSC (and in university), and it's so great to finally be able to break into frontend. Thank you!

  • @maciejka1
    @maciejka1 2 роки тому +1

    Thank you bro, best way for me to learn is to implement new things to my old projects! Thank you again!

    • @MyBaBB
      @MyBaBB 10 місяців тому

      Me too!

  • @souvikguria1414
    @souvikguria1414 2 роки тому +8

    52:35 do add an empty dependecy array in useEffect, just to avoid re-rendering of component from firebse in an infinite loop

    • @souvikguria1414
      @souvikguria1414 2 роки тому

      since we are adding an empty dep. array here, your home screen will no longer auto re-render on post deletion, take care of that thing

    • @PedroTechnologies
      @PedroTechnologies  2 роки тому +2

      I forgot to do this in the video but yes, you do add a dependency array. And to re-render automatically post deletion you can just add the "deletePost" function to the array.

    • @bhaskarrijal
      @bhaskarrijal 2 роки тому +4

      This is important. Having an infinite loop of reads would mean Firestore's read quota would be hit within minutes.

    • @lambda.403
      @lambda.403 2 роки тому

      @@PedroTechnologies it still infinite loop of reads

  • @MyBaBB
    @MyBaBB 10 місяців тому

    Thanks, this is a good learning lesson. I will rip it apart over and over.

  • @juseok.cha24
    @juseok.cha24 2 роки тому +1

    I really enjoyed this video! Thank you! from South Korea

  • @nithinm0836
    @nithinm0836 2 роки тому

    Man, this is absolutely fabulous. I was thinking of every loopholes and you were instantly fixing it. Lots of respect 🔥🔥

  • @bilbo_gamers6417
    @bilbo_gamers6417 Рік тому

    Beautifully simple and easy to follow video. Thank you so much! This is a great tutorial for just setting up a workspace for developing a website in general imho. I mean, if you can make a blog like this, you can basically make anything.

  • @mateusoliveira5286
    @mateusoliveira5286 2 роки тому

    Dude, I was looking for something like this yesterday. You're awesome. Congratz from BR.

    • @amralaaeldin
      @amralaaeldin 2 роки тому +1

      Recently this happens to me with several channels 😅

    • @PedroTechnologies
      @PedroTechnologies  2 роки тому +1

      Hahaha I am happy to hear this :)

  • @smurfolissicus
    @smurfolissicus 2 роки тому +1

    Wow you really out did your self with this one, you get my thumbs up!

  • @WillSmith-qt7me
    @WillSmith-qt7me 2 роки тому +1

    Great job Pedro, useful Firebase video

  • @filip23128
    @filip23128 Рік тому

    Thanks Pedro, this was a very clear and well-structured and easy to follow explanation!

  • @monique2839
    @monique2839 2 роки тому +1

    Thank you so much for this tutorial Pedro! It really cleared up some of my doubts.

  • @elendil4543
    @elendil4543 2 роки тому

    Pedro is our dear savior, thank you so much buddy

  • @sl4ught3r94
    @sl4ught3r94 2 роки тому

    Bro your way of teaching is bliss. I liked it

  • @morsecode9689
    @morsecode9689 2 роки тому

    really wanted a blog app. and just in the first line of yt reccomendation it popped up and thnks God

  • @xXHelsingGamingXx
    @xXHelsingGamingXx 2 роки тому

    Yep, I am the first to like comment and share! :-) Amazing video!

  • @dvdcrnn5244
    @dvdcrnn5244 2 роки тому +8

    With the code below, you prevent infinite loop and you won't have to reload to see the updated posts
    const getPosts = async () => {
    try {
    const data = await getDocs(postsCollectionRef);
    setPostLists(
    data.docs.map((post) => ({
    ...post.data(),
    id: post.id,
    }))
    );
    } catch (err) {
    console.log(err);
    }
    };
    const deletePost = async (id) => {
    const postDoc = doc(db, "posts", id);
    await deleteDoc(postDoc);
    getPosts();
    };
    useEffect(() => {
    console.log("Effect called");
    getPosts();
    }, []);

    • @cosmovandam
      @cosmovandam Рік тому

      Thank you so much, this is exactly what I needed!
      Looking back at Pedro's original code, could you please explain why useEffect creates an infinite loop error when deletePosts is placed within the dependcy arrary? Why is it not only rerendering once whenever I delete something? Why does it instead rerender infinitely without me deleting anything?

    • @dvdcrnn5244
      @dvdcrnn5244 Рік тому +1

      @@cosmovandam When we want to delete a post we call the deletePost function which call the getPosts() function. Inside the getPosts() function you set a new state (setPostsLists) to store Posts. So if you put deletedPosts inside the dependency array, the state will be updated and rerender infinitely. Hope it helps !

    • @zaurhuseyn4432
      @zaurhuseyn4432 Рік тому

      @@dvdcrnn5244i have problem with delete post in home.js can’t install page

    • @rodrigobarenco
      @rodrigobarenco Рік тому

      I would post this, I'm not so used to front end... when I saw it had made 50 thousand requests, quota exceed! I just forgot to put this:
      useEffect(() => {
      console.log("Effect called");
      getPosts();
      }, []);

  • @chinmayghule8272
    @chinmayghule8272 Рік тому +1

    I'm doing the same project but with a few changes. The users have their own page where they can see all their blogs. The delete button isn't on the homepage but on the user's own page inside the blog content card. I'm also going to try to add a feature so that the users would be able to update their blogs. Also, if time permits, I would even like to add a feature to enable the users to add tags to their blogs, and a search bar on the home page so that the users would be able to search by title, tags, or blog authors.

    • @ridwanbajuri4714
      @ridwanbajuri4714 Рік тому

      hy, how you query through the post collection? are you get all the post collection, or just get post by the users?

  • @CodeWithPrajwol
    @CodeWithPrajwol 2 роки тому

    Bro, you deserved millions of subscriber.

  • @sunitvarada
    @sunitvarada 2 роки тому +2

    Error in /~/pages/Home.js (59:29)
    Cannot read properties of undefined (reading 'name')
    how to resolve this issue!

  • @HendrieBeats
    @HendrieBeats 2 роки тому

    Awesome content man! Great work. Def going to look for more projects like this to learn soon!

  • @mikaela1119
    @mikaela1119 2 роки тому

    100% Clear and good explanation, its really helped me, thanks for the tutorial

  • @infojr83
    @infojr83 2 роки тому +3

    src\pages\Home.js
    Line 16:6: React Hook useEffect has a missing dependency: 'postsCollectionRef'. Either include it or remove the dependency array react-hooks/exhaustive-deps

    • @TechLifeTales
      @TechLifeTales Рік тому

      im getting the same error did you figure it out

  • @suraskumarnayak8350
    @suraskumarnayak8350 Рік тому

    Awesome tutorial. Just what I needed to get started.

  • @tsdineshjai8565
    @tsdineshjai8565 2 роки тому +3

    Excellent Project, Thank you pedro. The only thing i couldnt comprehend is how you extracted the data . I mean this part "setPostLists(data.docs.map((doc) => ({ ...doc.data(), id: doc.id })));". Could you explain in the forthcoming videos how to easily extract data no matter how deeply nested objects are.

  • @muahandneyma4517
    @muahandneyma4517 Рік тому

    great work mate am a big fan of your channel

  • @tusharubale1788
    @tusharubale1788 2 роки тому +2

    Bang on Thanks pedro for this CRUD WebApp
    Few Points to mention
    1. Hey Pedro have you updated you React Playlist according to increasing complexity
    2. If possible next time make video on Intersection-Observer-API

    • @PedroTechnologies
      @PedroTechnologies  2 роки тому

      Thank you! I haven't made a playlist arranged like that yet. Might do it soon :) I can take a look at making a video on the intersection-observer-api!

  • @rkarimov3995
    @rkarimov3995 2 роки тому +1

    Awesome tut, made me subscribe

  • @JoseCarlos-ym4ke
    @JoseCarlos-ym4ke 2 роки тому +1

    At 56:37 in the map function, ...doc.data(), is that data( ) some firebase method? I don't really get it

  • @ThColinPereira
    @ThColinPereira 2 роки тому

    Amazing video as always pedro!

  • @JOJO_THE_PROGRAMMER
    @JOJO_THE_PROGRAMMER 2 роки тому

    Another awesome video and funny thing is I was looking for blogging platform lol

    • @PedroTechnologies
      @PedroTechnologies  2 роки тому +1

      A lot of people are commenting this hahaha I don't know why I thought of posting this or why everyone wants to make a blog at the same time, but I am happy hahaha

  • @wesgarvin5998
    @wesgarvin5998 2 роки тому

    I love your passion. Thanks for the helpful video.

  • @ShayShmaya
    @ShayShmaya Рік тому

    Amazing video man ! helped me alot !! 👑👑👑

  • @mukulupadhyay4656
    @mukulupadhyay4656 2 роки тому

    Great tutorial easy to follow even for beginners like me.

  • @wallacce
    @wallacce 2 роки тому +1

    Excelente tutorial. Obrigado, Pedro.

  • @emirhansevincc
    @emirhansevincc 2 роки тому

    Many thanks for this beautiful project 💪💪

  • @napoleonbonaparte1260
    @napoleonbonaparte1260 2 роки тому

    Hello pedro, I noticed you do not have any videos about Docker or Nginx. It would be nice to create one coz this topics can move past an intermediate developer to advance. Keep it up brother.

  • @kondzio2003
    @kondzio2003 2 роки тому +1

    What is the name of plugin that calculating size of importing libs?

  • @ЗамирбекБайзаков
    @ЗамирбекБайзаков 2 роки тому

    I really like your videos. Thank you very much. 👍🏽👍🏽👍🏽

  • @azizul955
    @azizul955 2 роки тому

    Love from Bangladesh come from nasim Vai

  • @guideoutorg
    @guideoutorg 2 роки тому +1

    How can I order this data?
    I tried using queries and replacing the postCollectionRef with the query constant and it didn't work, any help?

  • @darnelldugger4859
    @darnelldugger4859 2 роки тому

    You're awesome bro! Thank you for this

  • @powerofhydrogen9443
    @powerofhydrogen9443 2 роки тому

    Thanks this was very helpful!

  • @abhaytiwari6411
    @abhaytiwari6411 2 роки тому

    Awesome as always 👍

  • @hamidr8391
    @hamidr8391 2 роки тому

    Thank you, exactly what i needed...

  • @RohanKumar-zg2kq
    @RohanKumar-zg2kq Рік тому +1

    getting a error in console , " cannot acces deletePost before intialization
    HELP!

  • @brunorocha9898
    @brunorocha9898 2 роки тому

    Amazing, nice teacher.. thank you

  • @twinkalsoni1914
    @twinkalsoni1914 2 роки тому +1

    Hey, can u teach how to to edit and update in this blog website

  • @wangaevans2378
    @wangaevans2378 2 роки тому

    You're the best man

  • @TC-gv9fs
    @TC-gv9fs 2 роки тому +1

    How would you add images for each post into the database with firebase ?

  • @alexshel8578
    @alexshel8578 2 роки тому

    amazing tutorial!)

  • @anmol-fzr
    @anmol-fzr 2 роки тому

    Great Work BRUH !!!!!!!!!!!!!!!!!!

  • @Navoshay
    @Navoshay 2 місяці тому

    hey pedro, you are the only person I understand on youtube so please help guide me, I made a project, it has auth, a blogspot like this and some ecom stuff, Ihave used react and firebase for all the stuff, is it good enough to write on the resume to grab an internship

  • @lucy2003-d8p
    @lucy2003-d8p Рік тому

    great content brooo

  • @mohdmiraj4220
    @mohdmiraj4220 2 роки тому

    Very helpful video keep it up

  • @jazilzaim
    @jazilzaim 2 роки тому

    amazing video! thank you so much!

  • @nurlanmehdiyev7428
    @nurlanmehdiyev7428 2 роки тому

    Thank you! You are best!

  • @Llytkm
    @Llytkm 2 роки тому

    Hi can you show how to add image for the specific blog post?

  • @_nawazpasha
    @_nawazpasha 2 роки тому +1

    Loved it 🔥, and also wanted to ask will you make video on web3 or your view on it?

    • @PedroTechnologies
      @PedroTechnologies  2 роки тому +3

      Thank you! I am still studying more and more about web3, when I feel like I can comfortably explain I can make a video on it :) I am very familiar with crypto, however all of the nft / metaverse stuff is new to me.

  • @itsarenite
    @itsarenite 2 роки тому

    Hi Please help me the submit button in createPost.js does not do anything I tested by console logging. seems like the prob is the await

  • @ttocsomDev
    @ttocsomDev 2 роки тому

    Thanks for this video it was very helpful. a single thing. when I check the console in the browser it tells me that each item in the list has to have a key. Which one can I use and where would you put it?
    Cheers

  • @irattio
    @irattio 8 місяців тому

    This might be a stupid question, but I am trying to follow your tutorial step by step and when I am trying to open the project in browser, the "npm start" does not work. Why?

  • @amanaswal11
    @amanaswal11 2 роки тому

    amazing project!

  • @izzatajan
    @izzatajan 8 місяців тому

    thank u so much man

  • @eltonsantosoficial
    @eltonsantosoficial Рік тому

    How I can create a page detail? Because you show all description in home, how could I show only a part and all other content in the detail page?

  • @amiralimohammadi2242
    @amiralimohammadi2242 2 роки тому

    amazing video. thanks alot

  • @draftgraphics
    @draftgraphics Рік тому

    this was a great tutorial. but I am having a problem....my home page is not rendering any posts even after Logging In...Help....

  • @pedroclealdev
    @pedroclealdev 2 роки тому

    Great video, Pedro! What font are you using in the code editor?

  • @panagiotis_thiv
    @panagiotis_thiv 2 роки тому

    Hello, I am really glad I found this video and your channel because they are really great, and I was looking for this short of a video for a while now. I have a question not so related to a problem, what kind of hosting would I need to use to run a site like this? Thanks :)

  • @infojr83
    @infojr83 2 роки тому +1

    please help
    src\pages\CreatePost.js
    Line 26:6: React Hook useEffect has missing dependencies: 'isAuth' and 'navigate'. Either include them or remove the dependency array react-hooks/exhaustive-deps
    src\pages\Home.js
    Line 16:6: React Hook useEffect has a missing dependency: 'postsCollectionRef'. Either include it or remove the dependency array react-hooks/exhaustive-deps

  • @AMoktar
    @AMoktar 2 роки тому

    Thanks man 💐💐💐

  • @cryptodev2615
    @cryptodev2615 2 роки тому +1

    Another great tutorial!
    For some reason, my posts wont update when I delete a single post. It DOES indeed delete from the database, and does refresh DOM after manual refresh, but it's not updating immediately. I have the function async, and in a useEffect. IDK? Help someone!?!

    • @PedroTechnologies
      @PedroTechnologies  2 роки тому +1

      Hey, I forgot to put the deletePost function in the useEffect dependency array. Sorry about that!

  • @roshangeorge97
    @roshangeorge97 2 роки тому

    thank you so much!

  • @DivyangiChaudhari
    @DivyangiChaudhari 2 роки тому

    How is the possibility that the user can change the IsAuth value for login from developer tools?

  • @fabiocarvalho9602
    @fabiocarvalho9602 Рік тому

    I creating my blog with react and firebase. The texts i am using are longer and have some white spaces between the paragraphs for easier reading. But firestore only stores strings in a continuous line and i cant display the text way i wanted. Is there a way the handle this?

  • @mma-dost
    @mma-dost 2 роки тому +1

    Is FIREBASE a prerequisite for this video ??

  • @cryptodev2615
    @cryptodev2615 2 роки тому

    How do we add properly security rules to our firebase firestore? In order to only have authenticated users manipulate data?

  • @guybec1111
    @guybec1111 2 роки тому +1

    Thank you so much but im trying to connect to the database but im getting a Module not found: Error: Package path ./firstore is not exported from package? any solutions anyone? The auth is working fine...

    • @izhaktadesa7379
      @izhaktadesa7379 2 роки тому

      I also have the same problem, I would be happy to share if it was solved for you, of course, share if you were able to solve it

    • @guybec1111
      @guybec1111 2 роки тому

      @@izhaktadesa7379 it was a typo, import from 'firebase/firestore' instead of firstore, i was missing the e in the 'fire'

  • @philip1078
    @philip1078 2 роки тому

    which visual studio ui extention are you using?

  • @shawky.khalil
    @shawky.khalil 2 роки тому

    🔴 Another reminder for you to add the timestamps 😅 & keep up the good work 👏💪

  • @annzrocky
    @annzrocky 2 роки тому

    In the morning i was searching for a react blog tutorial in YT. And i couldn't find a decent one.
    Now he has just uploaded a tutorial about react blog.
    Lemme ask you man
    What kind of ML are you using to read Subscribers mind?

    • @PedroTechnologies
      @PedroTechnologies  2 роки тому +1

      Hahaha I wish I had a ML model to know what to post! I just thought of this video randomly, I am glad people are wanting to watch it :)

  • @Beyram1501
    @Beyram1501 Рік тому +3

    This is not safe though, having that delete logic on the frontend is very unsafe and easily hackable

  • @sahilbadkul7130
    @sahilbadkul7130 2 роки тому

    Nice
    Can you please make a video on how to upload single and multiple images in firebase storage please

  • @sahilbadkul7130
    @sahilbadkul7130 2 роки тому

    and super video
    🤟

  • @AGELESS_RAHUL2001
    @AGELESS_RAHUL2001 8 місяців тому

    bro you don't know how much i love your videos

  • @ArshdeepSingh-vf2zl
    @ArshdeepSingh-vf2zl 2 роки тому

    Hey!! I had a doubt, while I was signing in through google the navigation component changed to the second state with the logout button but as soon as I clicked the create post button the navigation component goes back to the previous state. Please help me... Awesome vid bye the way.

  • @developer_hadi
    @developer_hadi 2 роки тому

    Can these articles indexed by google search console?

  • @NInja0x1Codes
    @NInja0x1Codes Рік тому

    7:55 yeah bro me too , I too hate doing CSS.

  • @bhagij7071
    @bhagij7071 2 роки тому

    Hi Pedro tech when i was running my code i am getting this error Module not found: Error: Can't resolve 'firebase/auth' in 'C:\Users\DELL\sampleprojects\src' could you please help me

  • @totoadventure4832
    @totoadventure4832 Рік тому

    thank you!