React & Infinite Scroll - IntersectionObserver

  Рет қаралды 19,987

Leigh Halliday

Leigh Halliday

Күн бұрын

Пікірлер: 73
@manphamquang552
@manphamquang552 4 жыл бұрын
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 жыл бұрын
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 жыл бұрын
Don't be nervous Ezwald, everything's gonna be ok :D
@ezwalduzumaki3161
@ezwalduzumaki3161 4 жыл бұрын
@@leighhalliday You seem to have a deep passion for programming, I love it too.
@dmytromoroz4451
@dmytromoroz4451 4 жыл бұрын
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 жыл бұрын
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
@leighhalliday
@leighhalliday 2 жыл бұрын
Glad you enjoyed it Jatan!
@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!
@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 жыл бұрын
Thank you Dominik!! I appreciate it!
@rellify3
@rellify3 2 жыл бұрын
Great explanation!
@leighhalliday
@leighhalliday 2 жыл бұрын
Thanks Spencer!
@AdamsApples46
@AdamsApples46 3 жыл бұрын
suupeer aaaawesseome! thank you!
@gagate81
@gagate81 2 жыл бұрын
Amaizing! TY so much!
@leighhalliday
@leighhalliday 2 жыл бұрын
You're very welcome!
@KMRakibulIslam
@KMRakibulIslam 5 жыл бұрын
Great video, as usual, Leigh! :)
@leighhalliday
@leighhalliday 5 жыл бұрын
Thanks Rakib! I appreciate it :)
@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 :).
@leighhalliday
@leighhalliday 2 жыл бұрын
Happy you enjoyed it!
@youissac5401
@youissac5401 3 жыл бұрын
BEST!!! Thank you!!!!!!!!!!!!!!
@AshishRawat-zl6te
@AshishRawat-zl6te 3 жыл бұрын
Amazing and really informative video.
@leighhalliday
@leighhalliday 3 жыл бұрын
Thank you Ashish!!
@zAkRZa59
@zAkRZa59 3 жыл бұрын
Thanks, you just saved my job!
@leighhalliday
@leighhalliday 3 жыл бұрын
Phew! Glad you still have your job!
@viktorsuvorov8888
@viktorsuvorov8888 3 жыл бұрын
Thank you!
@Krishtal3
@Krishtal3 3 жыл бұрын
Great tutorial, thanks men
@leighhalliday
@leighhalliday 3 жыл бұрын
You're very welcome! Glad you enjoyed the video :)
@lukechopper22
@lukechopper22 3 жыл бұрын
Thank You So Much!
@leighhalliday
@leighhalliday 3 жыл бұрын
You're very welcome!
@tianyidrinkmorewater
@tianyidrinkmorewater 3 жыл бұрын
Great stuff. However my gut is telling me that the useRef + useEffect combo can be rewritten with either useCallback or useMemo?
@anuraghazra4772
@anuraghazra4772 5 жыл бұрын
Nice. Thanks for this. 😊
@leighhalliday
@leighhalliday 5 жыл бұрын
No problem, Anurag! :D
@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?
@surajprasanna2493
@surajprasanna2493 4 жыл бұрын
thanks a lot for the video
@leighhalliday
@leighhalliday 4 жыл бұрын
No prob, Suraj!! Glad you found it helpful.
@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.
@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 жыл бұрын
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?
@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!
@rajathongal7669
@rajathongal7669 3 жыл бұрын
Can you tell how to do this for reverse scroll? great video by the wayd
@ladislavhric5190
@ladislavhric5190 2 жыл бұрын
"btfullly styled green button..." LOL
@mortezatourani7772
@mortezatourani7772 4 жыл бұрын
I think `observer` could be a simply memoized with useMemo. Where I go wrong?
@leighhalliday
@leighhalliday 4 жыл бұрын
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?
@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 жыл бұрын
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.
@Meugur
@Meugur 2 жыл бұрын
smart
@straxico
@straxico 5 жыл бұрын
nice
@leighhalliday
@leighhalliday 5 жыл бұрын
Thanks, Mehran!
@BearkFearGamer
@BearkFearGamer 5 жыл бұрын
Muito bom mesmo!
@leighhalliday
@leighhalliday 4 жыл бұрын
Obrigado!
@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 жыл бұрын
Nice! Always happy when you can take my examples and improve them!
React and Intersection Observer
21:24
Leigh Halliday
Рет қаралды 26 М.
Infinite Scrolling in React using Intersection Observer
29:35
Frontend Interview Pro
Рет қаралды 1,8 М.
When u fight over the armrest
00:41
Adam W
Рет қаралды 7 МЛН
Ouch.. 🤕⚽️
00:25
Celine Dept
Рет қаралды 33 МЛН
Fake watermelon by Secret Vlog
00:16
Secret Vlog
Рет қаралды 37 МЛН
Человек паук уже не тот
00:32
Miracle
Рет қаралды 3,3 МЛН
React Data Fetching with Hooks using SWR
18:11
Leigh Halliday
Рет қаралды 28 М.
Forms in React with Formik
23:58
Leigh Halliday
Рет қаралды 22 М.
Learn Intersection Observer In 15 Minutes
15:32
Web Dev Simplified
Рет қаралды 339 М.
Infinite Scrolling With React - Tutorial
25:28
Web Dev Simplified
Рет қаралды 364 М.
React Hooks: useReducer
19:38
Leigh Halliday
Рет қаралды 7 М.
React JS Infinite Scroll | React Interview Questions | Machine Coding Round
28:53
Infinite Scroll in React | Full Tutorial
38:53
Dave Gray
Рет қаралды 51 М.
When u fight over the armrest
00:41
Adam W
Рет қаралды 7 МЛН