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.
@leighhalliday4 жыл бұрын
Thanks, Man!! Share with your friends and family, pets and co-workers! I appreciate it!
@errinwright3 жыл бұрын
@@leighhalliday Aunts and uncles and cousins and tribe members!!
@Daniel-wx9wz5 жыл бұрын
Thank you, Leigh. I hope you hit a million subscribers one day because you deserve it
@leighhalliday5 жыл бұрын
Thank you Daniel!! Hahah... I hope so too!! :)
@ezwalduzumaki31614 жыл бұрын
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
@leighhalliday4 жыл бұрын
Don't be nervous Ezwald, everything's gonna be ok :D
@ezwalduzumaki31614 жыл бұрын
@@leighhalliday You seem to have a deep passion for programming, I love it too.
@dmytromoroz44514 жыл бұрын
Leigh, thank you for sharing your knowledge! This video helped me to implement Infinite Scroll in my step project :)
@leighhalliday4 жыл бұрын
Nice!! That's awesome! Glad I could help a bit :)
@ScottSpencePlease5 жыл бұрын
initialisation 👍 Thanks for this Leigh, I was doing it without useRef I'm going to try this way too
@leighhalliday5 жыл бұрын
Oooo nice! Let me know if that helps, Scott!! Thanks for watching and leaving a comment :)
@MrJatan902 жыл бұрын
Man, thank you so for such amazing tutorial. Nice reproducible example and clear explanation
@leighhalliday2 жыл бұрын
Glad you enjoyed it Jatan!
@pierrickleroy70564 жыл бұрын
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!
@leighhalliday4 жыл бұрын
:) thank you Pierrick! Glad you enjoyed it!
@psuprav4 жыл бұрын
Thank you Leigh. I love your videos. Everything is explained so well!
@leighhalliday4 жыл бұрын
Thanks for the kind words, Pravesh! I'm glad you enjoy them :)
@dominikseljan30435 жыл бұрын
This is so cool. Thanks Leigh for another great video 🙂
@leighhalliday5 жыл бұрын
Thank you Dominik!! I appreciate it!
@rellify32 жыл бұрын
Great explanation!
@leighhalliday2 жыл бұрын
Thanks Spencer!
@AdamsApples463 жыл бұрын
suupeer aaaawesseome! thank you!
@gagate812 жыл бұрын
Amaizing! TY so much!
@leighhalliday2 жыл бұрын
You're very welcome!
@KMRakibulIslam5 жыл бұрын
Great video, as usual, Leigh! :)
@leighhalliday5 жыл бұрын
Thanks Rakib! I appreciate it :)
@ashwiniravinair35634 жыл бұрын
Hello Sir...this video was very informative and helped me solve an issue I was facing.. thank you
@leighhalliday4 жыл бұрын
Hey Ashwini! Thanks for saying hi :) Happy I could help!
@tamaraevpraksina69452 жыл бұрын
Hello!!! Thank you so much for great video and explication :).
@leighhalliday2 жыл бұрын
Happy you enjoyed it!
@youissac54013 жыл бұрын
BEST!!! Thank you!!!!!!!!!!!!!!
@AshishRawat-zl6te3 жыл бұрын
Amazing and really informative video.
@leighhalliday3 жыл бұрын
Thank you Ashish!!
@zAkRZa593 жыл бұрын
Thanks, you just saved my job!
@leighhalliday3 жыл бұрын
Phew! Glad you still have your job!
@viktorsuvorov88883 жыл бұрын
Thank you!
@Krishtal33 жыл бұрын
Great tutorial, thanks men
@leighhalliday3 жыл бұрын
You're very welcome! Glad you enjoyed the video :)
@lukechopper223 жыл бұрын
Thank You So Much!
@leighhalliday3 жыл бұрын
You're very welcome!
@tianyidrinkmorewater3 жыл бұрын
Great stuff. However my gut is telling me that the useRef + useEffect combo can be rewritten with either useCallback or useMemo?
@anuraghazra47725 жыл бұрын
Nice. Thanks for this. 😊
@leighhalliday5 жыл бұрын
No problem, Anurag! :D
@SofiaGoyal3 жыл бұрын
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?
@surajprasanna24934 жыл бұрын
thanks a lot for the video
@leighhalliday4 жыл бұрын
No prob, Suraj!! Glad you found it helpful.
@ahrbil5 жыл бұрын
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?
@leighhalliday5 жыл бұрын
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.
@jexxiewoo83905 жыл бұрын
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?
@leighhalliday5 жыл бұрын
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?
@bryanmichaelzapatacapcha67014 жыл бұрын
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 = (
@leighhalliday4 жыл бұрын
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?
@saidazkri1344 жыл бұрын
Why not to change to increment page number and changed in state with that example it can be done rapidly
@leighhalliday4 жыл бұрын
Hey Said! You can totally do that... up to you!
@rajathongal76693 жыл бұрын
Can you tell how to do this for reverse scroll? great video by the wayd
@ladislavhric51902 жыл бұрын
"btfullly styled green button..." LOL
@mortezatourani77724 жыл бұрын
I think `observer` could be a simply memoized with useMemo. Where I go wrong?
@leighhalliday4 жыл бұрын
What issues are you running into? Sorry, I forget this video now haha :D Short memory ;)
@rayetzki3 жыл бұрын
@@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.
@venXca4 жыл бұрын
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.
@leighhalliday4 жыл бұрын
Thanks venXca, I wasn't aware of a change and haven't seen any documentation... are you able to share?
@arjobansingh19404 жыл бұрын
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?
@leighhalliday4 жыл бұрын
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
@yadiracondezo77543 жыл бұрын
Hi, I don't understand the part about when you do the assignment to ref: ref = {setElement}? :(
@leighhalliday3 жыл бұрын
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.
@Meugur2 жыл бұрын
smart
@straxico5 жыл бұрын
nice
@leighhalliday5 жыл бұрын
Thanks, Mehran!
@BearkFearGamer5 жыл бұрын
Muito bom mesmo!
@leighhalliday4 жыл бұрын
Obrigado!
@satindersingh96712 жыл бұрын
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
@leighhalliday2 жыл бұрын
Nice! Always happy when you can take my examples and improve them!