React Infinite Scroll like YouTube, Instagram | with Animation

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • 🎓Get FREE access to my upcoming Ultimate Node.js Course for the FIRST 100 students: forms.gle/8m9X... 🚀
    🤩Access the Full React Course - www.udemy.com/...
    🗒️MY FAVORITE TOOLS & GEARS
    Height Adjustable Desk - amzn.to/42qPZkb
    Old Desk in Budget - amzn.to/3UlaFbm
    Favorite Laptop - amzn.to/3OrqmKa
    LG Monitor for Productivity - amzn.to/3uqA5tv
    Silent Keyboard(Loved It) - amzn.to/3UjagGv
    Mouse & Keyboard Combo - amzn.to/3Sq50hs
    Extra Large Mouse Pad - amzn.to/48Nhcjv
    Sony Headphones - amzn.to/3HHjYed
    Cheap Earphones for Editing - amzn.to/48eBykN
    Daily Use Laptop Stand - amzn.to/3Uj8JQL
    Mini Speakers for Consuming Content - amzn.to/48YgAaK
    Mport X Connector - amzn.to/3UoHsML
    Mic - amzn.to/48eCrtD
    3 Color Lightbar - amzn.to/42qgaaW
    Dual Monitor Stand - amzn.to/48Nixa1
    Stop Watch for Productivity - amzn.to/3Un1RBW
    Dotted Diary - amzn.to/3vYBWq1
    🚀Access REDUX Course:- www.udemy.com/...
    How to apply infinite scroll in ReactJS or you can say endless scroll in React. Infinite scrolling is the most common feature to hook user attention on website content and user will spent more time on our website. You will learn How to add infinite scroll in react with loading animation very fast.
    IMPORTANT LINKS
    API LINK : api.coingecko....
    Source Code : github.com/Cod...
    UseEffect Tutorial : • useEffect React Hook |...
    Axios Tutorial : • Axios in React JS // C...
    CSS Loader Tutorial: • 100+ Stunning CSS Load...
    Social Media Links:
    🚀COURSES : www.udemy.com/...
    🤩INSTAGRAM : / code_blessyou
    💙FACEBOOK : / 100077716056158
    🐦TWITTER : / code_blessyou
    😎LINKEDIN : / code-bless-you-5b76822b
    COPYRIGHT FOOTAGE LINKS
    Video by Anna Tarazevich: www.pexels.com...
    Video by cottonbro: www.pexels.com...
    Timer icons created by Pixel perfect - www.flaticon.c...
    TAGS
    react pagination,lazy loading,react infinite scroll,infinite scroll react,infinite scroll,endless scroll react,react unlimited scroll,infinite scroll tutorial,react infinite scrolling,endless scrolling react,infinite scroll react tutorial,react infinite scroll component,react infinite scroll functional component,infinite scrolling with react,infinite scrolling,reactjs infinite scroll,infinite scroll reactjs,react,react infinite,react js
    Infinite Scrolling With React - Tutorial Infinite Scroll React Example Using React-Infinite-Scroll-Component Infinite Scrolling in React | JavaScript Infinite Scrolling | Pagination in React JS in Hindi How to Code an Infinite Scroller with React Hooks

Komentáře • 92

  • @CodeBlessYou
    @CodeBlessYou  Před rokem +6

    In this scrolling condition, at the bottom we by mistake sending multiple requests. So you can replace that logic with this, This will call our function only one time:
    useEffect(() => {
    window.addEventListener("scroll", handleScroll);
    return () => window.removeEventListener("scroll", handleScroll);
    }, []);
    const handleScroll = () => {
    const { scrollTop, clientHeight, scrollHeight } =
    document.documentElement;
    if (scrollTop + clientHeight >= scrollHeight) {
    setPage((prev) => prev + 1);
    }
    };
    🎓Get FREE access to my upcoming Ultimate Node.js Course for the FIRST 100 students: forms.gle/8m9XA7kmc17nHfhz8 🚀

  • @canklc5772
    @canklc5772 Před rokem +14

    For infinite scroll, I have watched several videos. This one is the best. No rocket science. Simple and on point. Thanks a lot Mate.

  • @devworks8787
    @devworks8787 Před 8 měsíci +2

    wow... very clean explanation and straight to the code. Subbed!

  • @abdelhakmehda
    @abdelhakmehda Před 2 lety +2

    all your explanation are so clear ... you are amazing , keep going bro❤

  • @thesankharoy
    @thesankharoy Před rokem +1

    All of your videos are really helpful to me. I learn a lot in very short time.

    • @CodeBlessYou
      @CodeBlessYou  Před rokem

      Thanks for your support. Grateful for that❤❤

  • @fullycodedtech
    @fullycodedtech Před 3 měsíci

    I have seen many videos of more then 30 minutes to explain the same concept but you explained 1000 times better in just 7 minutes ❤

  • @sravanstg234
    @sravanstg234 Před 6 měsíci

    Thank you for such simple explanation.

  • @francoagustin765
    @francoagustin765 Před rokem

    Good tutorial, I haven't seen one like it. others had a lot of logic that when applying it I forgot everything. One thing that I would need is to verify that it does not look for more data if there is no next page.

    • @CodeBlessYou
      @CodeBlessYou  Před rokem +1

      For that you need to get total number of posts from your backend and after that you can do - ( totalPosts/postsPerPage ) This will return total number of page and then in codition, you have to put page

  • @roycechriston5389
    @roycechriston5389 Před 4 měsíci

    Thank you soo much If a get a job because of this you will be treated 😍😇

  • @vishnumurthyjadi4704
    @vishnumurthyjadi4704 Před rokem

    I have watched several videos.your explanation excellent.thanks a lot . please do more videos on React.

    • @CodeBlessYou
      @CodeBlessYou  Před rokem

      Actually I am creating Complete React JS course, If you are interested then you can register for that. For first 100 Students it will completely FREE.
      Fill This Form:- forms.gle/aBtV1aRdcbztDwF3A

  • @r.vamsi-1657
    @r.vamsi-1657 Před 2 měsíci

    when the scroll is in subcontainer of whole window, and if we want implement scroll in that container will this work?

    • @CodeBlessYou
      @CodeBlessYou  Před 2 měsíci

      For that you have to track scroll for that container

  • @user-tu2vp4ww5b
    @user-tu2vp4ww5b Před měsícem +1

    can you make the like facebook remove recent videos,post, when keep scrolling

    • @CodeBlessYou
      @CodeBlessYou  Před měsícem +1

      We can create that, but for that we need to change in the backend. Because the data we want to show, i coming from backend.

    • @user-tu2vp4ww5b
      @user-tu2vp4ww5b Před měsícem

      @@CodeBlessYou Im so excited for v2 of this . keep it up

    • @CodeBlessYou
      @CodeBlessYou  Před měsícem

      @@user-tu2vp4ww5b ❤❤❤

  • @quanganh2849
    @quanganh2849 Před rokem

    Simple and on point. Tks a lot bro keep doing

  • @sauravkhanal
    @sauravkhanal Před 4 měsíci

    Really cool man, may the code bless you🖖

  • @muhammadfaizantariq7841
    @muhammadfaizantariq7841 Před 5 měsíci

    Amazing Tutorial for infinite scroll with loading
    Really helpful

    • @CodeBlessYou
      @CodeBlessYou  Před 5 měsíci +1

      ❤❤❤

    • @muhammadfaizantariq7841
      @muhammadfaizantariq7841 Před 5 měsíci

      @@CodeBlessYou , I'm facing issue when I reach the last product then api call is invoke and loading is keeping going so How I can avoid it, and one last thing on scroll event api call multiple time

    • @CodeBlessYou
      @CodeBlessYou  Před 5 měsíci

      @@muhammadfaizantariq7841 Put condition, if isLoading is true then don't update page state

  • @LaFragas
    @LaFragas Před rokem

    super fast and perfect, thank you!

  • @mauriciochambi2508
    @mauriciochambi2508 Před 4 měsíci

    How can I avoid data duplication in the first API call? I'm using Next.js

  • @simple-stack-by-ed
    @simple-stack-by-ed Před 3 měsíci

    Straighter than an heterosexual alpha silverback man. Thx man!

  • @guesswho4633
    @guesswho4633 Před rokem

    i really love your videos. helps a lot

  • @rezafirouzabadi176
    @rezafirouzabadi176 Před rokem

    thanks for the short and useful video brother

  • @shubhamrathod5933
    @shubhamrathod5933 Před 18 dny

    Which VS code theme are you using ?

  • @athulgeorge4873
    @athulgeorge4873 Před rokem +1

    Great Tutorial, just wondering if we were to use a our own rest api, would we limit and offset to get the next data be ideal? Also how do we keep the loading animation for longer, setting the loading state to false within a setTimeout is not working for me.

    • @CodeBlessYou
      @CodeBlessYou  Před rokem

      Check setTimeout function if there are some error

  • @immanuelrajmohan830
    @immanuelrajmohan830 Před 2 lety

    thank u bruh very short and simple

  • @keerthanamalisetty7487
    @keerthanamalisetty7487 Před 2 lety +1

    It would help if u show us how to do this with backend also with nodejs and mongodb

    • @CodeBlessYou
      @CodeBlessYou  Před 2 lety +1

      I will upload tutorial on that, If you want to try Right now then...
      Use limit and skip function in find method of mongoDB...

  • @vaibhavsingh6668
    @vaibhavsingh6668 Před 2 měsíci

    Yes bro I have doubt in infinite loading in the couse i have purchase from udemy. React js 2024.

    • @CodeBlessYou
      @CodeBlessYou  Před 2 měsíci

      Whats you doubt?

    • @vaibhavsingh6668
      @vaibhavsingh6668 Před 2 měsíci

      @@CodeBlessYou can't implement infinite loading i am following your code along

  • @omarbarra3456
    @omarbarra3456 Před rokem

    Thank very useful. question, why do not you use a Intersection Observer API? when shold we use eventListener or Intersection Observer API?

    • @CodeBlessYou
      @CodeBlessYou  Před rokem

      You can use both for infinite scrolling. This is the easy way to do that

  • @sakibcoder
    @sakibcoder Před 6 měsíci

    great man

  • @pelumioye4196
    @pelumioye4196 Před rokem

    hey man, wonderful tutorial but what do i do if i'm using my own server/backend and not a link that has "per_page and page=" ?

    • @CodeBlessYou
      @CodeBlessYou  Před rokem +1

      Then you have to create API which send posts by page number. When user reach to bottom of page, then you have to call API for that.

  • @growwithdesign
    @growwithdesign Před rokem

    I have my own API file created in my react project, where I am manually maintaining records. How to use your own API file instead of using an external url?

    • @CodeBlessYou
      @CodeBlessYou  Před rokem

      Sorry I don't have clear understanding about that

  • @dhruvkaravadiya3645
    @dhruvkaravadiya3645 Před rokem

    amazing video bhai

  • @antrikshsingh2503
    @antrikshsingh2503 Před 2 lety

    Well Explained :)

  • @Chavaka_cheap
    @Chavaka_cheap Před 3 měsíci

  • @alpalasaul
    @alpalasaul Před 7 měsíci

    What is that theme you use?

  • @giovankoulits8602
    @giovankoulits8602 Před rokem

    Very helpful vid

  • @weverton.santiago
    @weverton.santiago Před rokem

    Thanks new subs here

  • @anikbarua5483
    @anikbarua5483 Před rokem

    Suppose i have my own json data that doesn't come from any api so how to add page number in this data?

    • @CodeBlessYou
      @CodeBlessYou  Před rokem +2

      In that case, you have to set two variables: currentPage=1 and postsPerPage=8,
      Now when you reach to bottom, then currentPage will 2 and you have to skip (currentPage - 1)*postsPerPage which is 8, so you have to skip 8 posts from your json data.
      If your currentPage is 3 then you have to skip first 16 posts from your json data.
      If you already have data offline in your application, then you don't need to add pagination or infinite scrolling. They are just for reducing the data load to server.

  • @jritzeku
    @jritzeku Před rokem

    Any examples with Redux ? Also isn''t it bad to be making multiple network requests as you are here every 500ms?

    • @CodeBlessYou
      @CodeBlessYou  Před rokem +1

      I find that in this scrolling condition, at the bottom we by mistake sending multiple requests. So you can replace this logic with this, This will call our function only one time:
      useEffect(() => {
      window.addEventListener("scroll", handleScroll);
      return () => window.removeEventListener("scroll", handleScroll);
      }, []);
      const handleScroll = () => {
      const { scrollTop, clientHeight, scrollHeight } =
      document.documentElement;
      if (scrollTop + clientHeight >= scrollHeight) {
      setPage((prev) => prev + 1);
      }
      };

  • @Its_Abhi_Thakur
    @Its_Abhi_Thakur Před 2 lety

    Thanks bro

  • @sandhyaginare857
    @sandhyaginare857 Před rokem

    Can we do the same if we are getting the data from dummy json file?????

    • @CodeBlessYou
      @CodeBlessYou  Před rokem

      In that case, we don't want Infinite scrolling, we can simply display the data. Because Infinite scrolling essentially for reducing load to server for not sending 100posts in one request.

  • @AdityaSharan811
    @AdityaSharan811 Před rokem

    U cannot make callback inside useEffect as async !!

    • @CodeBlessYou
      @CodeBlessYou  Před rokem +1

      Yes, You can declare async function outside of the useEffects and then call that function in useEffect

  • @charankumarbasam5866
    @charankumarbasam5866 Před 2 lety

    make a video on intersection observer

  • @charankumarbasam5866
    @charankumarbasam5866 Před 2 lety

    Good video.

  • @mylow_____
    @mylow_____ Před 2 lety

    yeeeeessssss

  • @anjalii1102
    @anjalii1102 Před rokem

    are you gujarati

    • @CodeBlessYou
      @CodeBlessYou  Před rokem

      Yes😄😄 Did you notice that? You are good observer