React Infinite Scroll like YouTube, Instagram | with Animation

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ก.ย. 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

ความคิดเห็น • 92

  • @CodeBlessYou
    @CodeBlessYou  ปีที่แล้ว +7

    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 ปีที่แล้ว +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.

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว +1

      Thanks for this comment😇❤

  • @devworks8787
    @devworks8787 8 หลายเดือนก่อน +2

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

    • @CodeBlessYou
      @CodeBlessYou  8 หลายเดือนก่อน +1

      Thank you so much❤❤❤

  • @abdelhakmehda
    @abdelhakmehda 2 ปีที่แล้ว +2

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

  • @thesankharoy
    @thesankharoy ปีที่แล้ว +1

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

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

      Thanks for your support. Grateful for that❤❤

  • @fullycodedtech
    @fullycodedtech 3 หลายเดือนก่อน

    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 ❤

    • @CodeBlessYou
      @CodeBlessYou  3 หลายเดือนก่อน

      Glad to here that❤❤❤

  • @sauravkhanal
    @sauravkhanal 4 หลายเดือนก่อน

    Really cool man, may the code bless you🖖

    • @CodeBlessYou
      @CodeBlessYou  4 หลายเดือนก่อน

      Thanks, Same to you❤❤❤

  • @quanganh2849
    @quanganh2849 ปีที่แล้ว

    Simple and on point. Tks a lot bro keep doing

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

      Thanks for your support❤❤

  • @LaFragas
    @LaFragas ปีที่แล้ว

    super fast and perfect, thank you!

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

      Thank you so much for this comment❤

  • @sravanstg234
    @sravanstg234 6 หลายเดือนก่อน

    Thank you for such simple explanation.

  • @guesswho4633
    @guesswho4633 ปีที่แล้ว

    i really love your videos. helps a lot

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

      Grateful for your support 😇❤

  • @francoagustin765
    @francoagustin765 ปีที่แล้ว

    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  ปีที่แล้ว +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

  • @rezafirouzabadi176
    @rezafirouzabadi176 ปีที่แล้ว

    thanks for the short and useful video brother

  • @vishnumurthyjadi4704
    @vishnumurthyjadi4704 ปีที่แล้ว

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

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

      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 2 หลายเดือนก่อน

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

    • @CodeBlessYou
      @CodeBlessYou  2 หลายเดือนก่อน

      For that you have to track scroll for that container

  • @immanuelrajmohan830
    @immanuelrajmohan830 2 ปีที่แล้ว

    thank u bruh very short and simple

  • @athulgeorge4873
    @athulgeorge4873 ปีที่แล้ว +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  ปีที่แล้ว

      Check setTimeout function if there are some error

  • @roycechriston5389
    @roycechriston5389 4 หลายเดือนก่อน

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

    • @CodeBlessYou
      @CodeBlessYou  4 หลายเดือนก่อน

      Sure, All the best❤❤❤

  • @shubhamrathod5933
    @shubhamrathod5933 24 วันที่ผ่านมา

    Which VS code theme are you using ?

    • @CodeBlessYou
      @CodeBlessYou  23 วันที่ผ่านมา

      AYU MIRAGE BORDER

  • @user-tu2vp4ww5b
    @user-tu2vp4ww5b หลายเดือนก่อน +1

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

    • @CodeBlessYou
      @CodeBlessYou  หลายเดือนก่อน +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 หลายเดือนก่อน

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

    • @CodeBlessYou
      @CodeBlessYou  หลายเดือนก่อน

      @@user-tu2vp4ww5b ❤❤❤

  • @simple-stack-by-ed
    @simple-stack-by-ed 3 หลายเดือนก่อน

    Straighter than an heterosexual alpha silverback man. Thx man!

    • @CodeBlessYou
      @CodeBlessYou  3 หลายเดือนก่อน

      😅😅❤❤

  • @muhammadfaizantariq7841
    @muhammadfaizantariq7841 6 หลายเดือนก่อน

    Amazing Tutorial for infinite scroll with loading
    Really helpful

    • @CodeBlessYou
      @CodeBlessYou  5 หลายเดือนก่อน +1

      ❤❤❤

    • @muhammadfaizantariq7841
      @muhammadfaizantariq7841 5 หลายเดือนก่อน

      @@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  5 หลายเดือนก่อน

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

  • @antrikshsingh2503
    @antrikshsingh2503 2 ปีที่แล้ว

    Well Explained :)

  • @mauriciochambi2508
    @mauriciochambi2508 4 หลายเดือนก่อน

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

    • @CodeBlessYou
      @CodeBlessYou  4 หลายเดือนก่อน

      You have to work with page number

  • @sakibcoder
    @sakibcoder 6 หลายเดือนก่อน

    great man

  • @dhruvkaravadiya3645
    @dhruvkaravadiya3645 ปีที่แล้ว

    amazing video bhai

  • @giovankoulits8602
    @giovankoulits8602 ปีที่แล้ว

    Very helpful vid

  • @omarbarra3456
    @omarbarra3456 ปีที่แล้ว

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

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

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

  • @keerthanamalisetty7487
    @keerthanamalisetty7487 2 ปีที่แล้ว +1

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

    • @CodeBlessYou
      @CodeBlessYou  2 ปีที่แล้ว +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 2 หลายเดือนก่อน

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

    • @CodeBlessYou
      @CodeBlessYou  2 หลายเดือนก่อน

      Whats you doubt?

    • @vaibhavsingh6668
      @vaibhavsingh6668 2 หลายเดือนก่อน

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

  • @Chavaka_cheap
    @Chavaka_cheap 4 หลายเดือนก่อน

  • @alpalasaul
    @alpalasaul 7 หลายเดือนก่อน

    What is that theme you use?

    • @CodeBlessYou
      @CodeBlessYou  7 หลายเดือนก่อน

      AYU Dark❤❤

  • @weverton.santiago
    @weverton.santiago ปีที่แล้ว

    Thanks new subs here

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

      Thanks for subscribing😇❤

  • @Its_Abhi_Thakur
    @Its_Abhi_Thakur 2 ปีที่แล้ว

    Thanks bro

    • @CodeBlessYou
      @CodeBlessYou  2 ปีที่แล้ว +1

      Thanks for Feedback😀

  • @pelumioye4196
    @pelumioye4196 ปีที่แล้ว

    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  ปีที่แล้ว +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 ปีที่แล้ว

    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  ปีที่แล้ว

      Sorry I don't have clear understanding about that

  • @charankumarbasam5866
    @charankumarbasam5866 2 ปีที่แล้ว

    Good video.

  • @jritzeku
    @jritzeku ปีที่แล้ว

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

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว +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);
      }
      };

  • @mylow_____
    @mylow_____ 2 ปีที่แล้ว

    yeeeeessssss

  • @anikbarua5483
    @anikbarua5483 ปีที่แล้ว

    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  ปีที่แล้ว +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.

  • @sandhyaginare857
    @sandhyaginare857 ปีที่แล้ว

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

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

      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.

  • @charankumarbasam5866
    @charankumarbasam5866 2 ปีที่แล้ว

    make a video on intersection observer

  • @AdityaSharan811
    @AdityaSharan811 ปีที่แล้ว

    U cannot make callback inside useEffect as async !!

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว +1

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

  • @anjalii1102
    @anjalii1102 ปีที่แล้ว

    are you gujarati

    • @CodeBlessYou
      @CodeBlessYou  ปีที่แล้ว

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