React & Infinite Scroll - IntersectionObserver

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

КОМЕНТАРІ • 73

  • @manphamquang552
    @manphamquang552 4 роки тому +5

    OMG thank you so much, all the other tutorial that I've read and the doc it self is really difficult to understand. Thank you for explaining this so well, I'm gonna share this to my friends.

    • @leighhalliday
      @leighhalliday  4 роки тому

      Thanks, Man!! Share with your friends and family, pets and co-workers! I appreciate it!

    • @errinwright
      @errinwright 3 роки тому

      @@leighhalliday Aunts and uncles and cousins and tribe members!!

  • @Daniel-wx9wz
    @Daniel-wx9wz 5 років тому +1

    Thank you, Leigh. I hope you hit a million subscribers one day because you deserve it

    • @leighhalliday
      @leighhalliday  5 років тому

      Thank you Daniel!! Hahah... I hope so too!! :)

  • @ezwalduzumaki3161
    @ezwalduzumaki3161 4 роки тому

    I was nervous in the beginning when you showed the load more button, thinking that this is not with intersection observer xD. Great video dude, wish you the best! I subscribed, looking forward to more content from you! Many Thanks :D

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

      Don't be nervous Ezwald, everything's gonna be ok :D

    • @ezwalduzumaki3161
      @ezwalduzumaki3161 4 роки тому +1

      @@leighhalliday You seem to have a deep passion for programming, I love it too.

  • @pierrickleroy7056
    @pierrickleroy7056 4 роки тому

    you had a hard time with instantiation but at least the light did not shut down this time. Very interesting to see advanced use cases with useRef and how you solved the closure issue!

    • @leighhalliday
      @leighhalliday  4 роки тому

      :) thank you Pierrick! Glad you enjoyed it!

  • @dmytromoroz4451
    @dmytromoroz4451 4 роки тому +1

    Leigh, thank you for sharing your knowledge! This video helped me to implement Infinite Scroll in my step project :)

    • @leighhalliday
      @leighhalliday  4 роки тому

      Nice!! That's awesome! Glad I could help a bit :)

  • @ScottSpencePlease
    @ScottSpencePlease 5 років тому +2

    initialisation 👍
    Thanks for this Leigh, I was doing it without useRef I'm going to try this way too

    • @leighhalliday
      @leighhalliday  5 років тому

      Oooo nice! Let me know if that helps, Scott!! Thanks for watching and leaving a comment :)

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

    Man, thank you so for such amazing tutorial. Nice reproducible example and clear explanation

  • @psuprav
    @psuprav 4 роки тому

    Thank you Leigh. I love your videos. Everything is explained so well!

    • @leighhalliday
      @leighhalliday  4 роки тому

      Thanks for the kind words, Pravesh! I'm glad you enjoy them :)

  • @dominikseljan3043
    @dominikseljan3043 5 років тому

    This is so cool. Thanks Leigh for another great video 🙂

    • @leighhalliday
      @leighhalliday  5 років тому +1

      Thank you Dominik!! I appreciate it!

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

    Great explanation!

  • @AdamsApples46
    @AdamsApples46 3 роки тому

    suupeer aaaawesseome! thank you!

  • @gagate81
    @gagate81 3 роки тому

    Amaizing! TY so much!

  • @AshishRawat-zl6te
    @AshishRawat-zl6te 3 роки тому

    Amazing and really informative video.

  • @ashwiniravinair3563
    @ashwiniravinair3563 4 роки тому

    Hello Sir...this video was very informative and helped me solve an issue I was facing.. thank you

    • @leighhalliday
      @leighhalliday  4 роки тому

      Hey Ashwini! Thanks for saying hi :) Happy I could help!

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

    Hello!!! Thank you so much for great video and explication :).

  • @KMRakibulIslam
    @KMRakibulIslam 5 років тому

    Great video, as usual, Leigh! :)

  • @zAkRZa59
    @zAkRZa59 3 роки тому

    Thanks, you just saved my job!

  • @SofiaGoyal
    @SofiaGoyal 3 роки тому

    Could you also tell how to update the count of the elements loaded ... ? i mean i can do it while scrolling down, but how to do it when scrolling up?

  • @tianyidrinkmorewater
    @tianyidrinkmorewater 3 роки тому

    Great stuff. However my gut is telling me that the useRef + useEffect combo can be rewritten with either useCallback or useMemo?

  • @lukechopper22
    @lukechopper22 3 роки тому

    Thank You So Much!

  • @anuraghazra4772
    @anuraghazra4772 5 років тому +1

    Nice. Thanks for this. 😊

  • @Krishtal3
    @Krishtal3 4 роки тому

    Great tutorial, thanks men

    • @leighhalliday
      @leighhalliday  4 роки тому

      You're very welcome! Glad you enjoyed the video :)

  • @youissac5401
    @youissac5401 3 роки тому

    BEST!!! Thank you!!!!!!!!!!!!!!

  • @viktorsuvorov8888
    @viktorsuvorov8888 3 роки тому

    Thank you!

  • @rajathongal7669
    @rajathongal7669 3 роки тому

    Can you tell how to do this for reverse scroll? great video by the wayd

  • @ahrbil
    @ahrbil 5 років тому

    Hello Leigh, thank you for your amazing videos
    I have a question can we wrap the load function in a useCallback hook instead of useRef?

    • @leighhalliday
      @leighhalliday  5 років тому

      Hey abd! Give it a try! I just ran into problems, not so much with it being updated too often, but how to get the IntersectionObserver callback function calling the correct version of the load function.

  • @surajprasanna2493
    @surajprasanna2493 4 роки тому

    thanks a lot for the video

    • @leighhalliday
      @leighhalliday  4 роки тому

      No prob, Suraj!! Glad you found it helpful.

  • @jexxiewoo8390
    @jexxiewoo8390 5 років тому

    nice video, thanks! 👍🏼 So one silly question, this technique will cause multiple api calls when scrolled to bottom, while virtual list, like react-virtualized, will fetch the data only once then choose to render them at different time, am I correct? What are the different use cases?

    • @leighhalliday
      @leighhalliday  5 років тому +2

      Hey Jexxie! Those solutions may be better for longer lists where it requires virtualization (not sure what the exact number is), but I don't believe this approach in the video caused multiple API calls every time you hit the bottom, just a single one at a time, no?

  • @bryanmichaelzapatacapcha6701
    @bryanmichaelzapatacapcha6701 4 роки тому

    Hello, I am applying the observer in a project in react and typescript and when I assign the "ref" to the div I get an error. I think it is the setElement that is null. Would someone help me please = (

    • @leighhalliday
      @leighhalliday  4 роки тому

      Hmmm... yea at the beginning the rer.current value may be null, until after the first render, so perhaps that is what is causing an issue?

  • @arjobansingh1940
    @arjobansingh1940 4 роки тому

    Hey I have a question, you are detting state again in return statement, means while rendering. React docs says we should avoid setting dtate in render method. As it will make infinite re-renders and app will crash, as setting state re-renders the component and after re-render we are just setting state. So why this is not crashing, or maybe I am missing something?

    • @leighhalliday
      @leighhalliday  4 роки тому

      Hey Arjoban! I don't think I'm setting state in the render of a component... maybe you could point to me in the code what you are thinking of? github.com/leighhalliday/demo-infinite-scroll/blob/master/src/WithIntersection.js

  • @yadiracondezo7754
    @yadiracondezo7754 3 роки тому

    Hi, I don't understand the part about when you do the assignment to ref: ref = {setElement}? :(

    • @leighhalliday
      @leighhalliday  3 роки тому +1

      I was placing the ref of the element into state here. If the value you pass to the ref prop is a function, it'll call that function passing in the reference.

  • @saidazkri134
    @saidazkri134 4 роки тому

    Why not to change to increment page number and changed in state with that example it can be done rapidly

    • @leighhalliday
      @leighhalliday  4 роки тому

      Hey Said! You can totally do that... up to you!

  • @mortezatourani7772
    @mortezatourani7772 4 роки тому

    I think `observer` could be a simply memoized with useMemo. Where I go wrong?

    • @leighhalliday
      @leighhalliday  4 роки тому +1

      What issues are you running into? Sorry, I forget this video now haha :D Short memory ;)

    • @rayetzki
      @rayetzki 3 роки тому

      @@leighhalliday What this guy is saying, is that instead of wrapping observer into ref you could've wrapped it into useMemo, and set load function as a dependency. Same thing but cleaner.

  • @venXca
    @venXca 4 роки тому

    Looks like the API has changed meanwhile and threshold:1 is not working like before.
    If you face issues, try using 0, or ignore passing options.

    • @leighhalliday
      @leighhalliday  4 роки тому

      Thanks venXca, I wasn't aware of a change and haven't seen any documentation... are you able to share?

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

    "btfullly styled green button..." LOL

  • @BearkFearGamer
    @BearkFearGamer 5 років тому

    Muito bom mesmo!

  • @straxico
    @straxico 5 років тому

    nice

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

    smart

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

    if we can create a new Intersection observer on every load without considerable performance loss and disconnect it in cleanup function then we don't need to create two useRef and two useEffect. One useState and useEffect could work. github.com/agnosticoder/next-infinite-scrolling

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

      Nice! Always happy when you can take my examples and improve them!