Hey!, just a simple tip that i use, is when you want to know if an array have elements (means its length is greather than 0), you only have to put array.length instead of array.length > 0, because if array.length is 0, 0 means false, and if is not 0 so is true, sorry if my english is bad.
when i click this video, i only expect to know how to implement infinity scroll. But after 25 minutes i have learned way more than that, like custom hook. Thank you so much
Man I have watched literally thousands of paid courses, but no course matches the level of explanation that this guy provides. Simply Amazing. Hats off!
That useCallback() behavior with useRef() that confused me, now I got it. Thank you Kyle, this is the best explanation about infinite scrolling with react 😍😍
Great to see a video that includes some of the more advanced React features. I'll definitely need to watch this again, which is a feature of the best code run through videos.
I think this deserves a clarification - it's not just useCallback that can be assigned to an element's ref. Any function can be passed there, you just need to be very careful if the function updates state, since it can cause infinite re-renders. Therefore, in this scenario, Kyle is right to use the useCallback hook, as the function he's using calls setPageNumber. Let's say he used a plain function: the function he's using sets the state at some point, which re-renders the component. When the component gets re-rendered, the function gets reinstantiated. Since it's passed to an element's ref, the element gets re-rendered, which calls the function again. The function changes the state, causing the component to re-render... and we have ourselves an infinite loop.
Awesome tutorial man. Straight to the point and well explained. Got an infinite scroll up and working in my application no problem after watching this. Subscribed!
Amazing! Thank you very much, I thought it would be harder to make something like this. Also THANKS because I finally got how to make a custom hook, I was having some struggles to get it.
its totally amazing. i dont know about intersection observer so was a bit confused there but the video was mind blowing. Thanks for explaining the idea behind the infinite scroll
There is one serious situation custom hooks can land into is when the arguments change, the useEffect inside hook is not called synchoronously, in fact it is called asynchronously whenever React wants, therefore, the very first render after the change of the arguments, hook will still return the stale data (in this case the books because of useState). I land into this issue when I was creating my useLocalStorage which takes a key. And when I change the key it still returns data for the old key. This scenario is well taken care by useSWR hook, the moment the API URL changes the data returned is different. Can you make a video regarding these advanced patterns in REACT sometime?. That would be wonderful!
Awesome tutorial mate! I suggest including "Custom React Hooks" in your title. I was actually pleasantly surprised that this tutorial was going to include custom hooks. If I had saw that in the title, I would have clicked on it way earlier since React Hooks is the hot thing that everyone should be learning now. Furthermore, now that I've saved this to my React playlist, I still won't know that it includes custom hooks when I scan through all the video titles.
Thank you for this tutorial! I got something similar workign, I just wanted the "isVisible" for one of my elements to show up. I think this video is a little too long, and getting the custom hook created is a little bit of a side job for getting infinite scrolling, and I would have preferred just getting the "isVisible" working, and then going from there. That being said, thanks for the info, your tutorials are always at a good pace, and I like that you've included the source code!
Didn't realize so little code was required for this. I'm too used to using libraries and I'm not aware of what Web APIs there are. Going to put an effort to learning more of these things and getting comfortable with web APIs like Intersection observers and setting it all up with refs and callbacks
Hey Kyle, thanks for the amazing tutorial, appreciate your work. I know this is an older video but had a quick question if you ever had the chance to read this, I can't figure out why the function inside the useCallback() where you defined the intersection observer get's called 4 times each time an intersection is observed. Best.
Its being called twice, the first time you feed the target (node ) to the observer and the second when the target intersects with its intersection root (the scrollable div container)
Hi Kyle, thank you for sharing the video. 17: 05 to 17: 46 min saved me. I never used two userEffect before, one to clean the state another to fetch data until I watched your video. I am implementing Cursor relay pagination. I had an issue about clearing old data. Whenever react-route changes I could get old data and new data repeatedly. I 've fixed the issue after 2 days struggling with your help. God bless you brother.
Very good tutorial, but what if we don't use axios, instead we are using vanilla xmlhttprequest, how do we do throttling effect in this circumstances ?
Using the ref on the children will force them to re-render when they're not the last item in the array, so maybe is better to use a the ref on a footer or something to observe the IntersectionObserver. And use useEffect to have the same functionality.
Great! I want to highlight that you keep adding new items to DOM, which will make DOM heavy. In this approach, We might have a large number of elements. How can we solve this issue? Is there any approach where we can maintain a specific set of items? No matter how long the list is.
Hi, first of all, owsm breakdown of the code... loved it, understood it. 1 QUERY, after loading 1 or 2 more page if the error occur, then along with Error... , Loading... is also present. Can you tell how to remove the loader if the error occurs?
Gotta say...this is probably the best, most straightforward tutorial I've ever seen!
why is openlibrary.org/search.json empty?
@@Mike37373 perhaps it needs params i.e.
axios({
method: 'GET',
url: url,
params: { q: query, page: pageNumber },
cancelToken: new axios.CancelToken(c => cancel = c)
}).then
i agree
Hey!, just a simple tip that i use, is when you want to know if an array have elements (means its length is greather than 0), you only have to put array.length instead of array.length > 0, because if array.length is 0, 0 means false, and if is not 0 so is true, sorry if my english is bad.
No need to apologize for your English. it was understandable.
Or you can just use the array, [] is falsy.
@@nishantmogha7679 array [] and {} are truthy brah
Also to make sure the app won't crash when array is null use optional chaining like myArr?.length
You can do that, but sometimes clearly code better than clever code
4 years later and this still works like a gem, Kudos to you!
when i click this video, i only expect to know how to implement infinity scroll. But after 25 minutes i have learned way more than that, like custom hook. Thank you so much
awesome video. infinite scrolling starts at 17:50
Man I have watched literally thousands of paid courses, but no course matches the level of explanation that this guy provides. Simply Amazing. Hats off!
I really have to say.. this was the best, clear, very staright forward tutorial. AWESOME
That useCallback() behavior with useRef() that confused me, now I got it. Thank you Kyle, this is the best explanation about infinite scrolling with react 😍😍
Kyle, you are great. Never found a tutor explaining such complex topics so easily. 😊
just from this video I have learned so many things, mainly the useRef and useCallback. thankyou
Great to see a video that includes some of the more advanced React features. I'll definitely need to watch this again, which is a feature of the best code run through videos.
I think this deserves a clarification - it's not just useCallback that can be assigned to an element's ref. Any function can be passed there, you just need to be very careful if the function updates state, since it can cause infinite re-renders.
Therefore, in this scenario, Kyle is right to use the useCallback hook, as the function he's using calls setPageNumber.
Let's say he used a plain function: the function he's using sets the state at some point, which re-renders the component. When the component gets re-rendered, the function gets reinstantiated. Since it's passed to an element's ref, the element gets re-rendered, which calls the function again. The function changes the state, causing the component to re-render... and we have ourselves an infinite loop.
Wonderful explanation!!
this literally just happened in class a few minutes ago in this example our TA was showing us...thank you now I understand why
Why can't we just create an reference using useRef and pass it to the component. Then Handel the intersection observer without a function.
Great explanation
Thanks for explaining that, this is the only section in the video that I needed more explanation on
Awesome tutorial man. Straight to the point and well explained. Got an infinite scroll up and working in my application no problem after watching this. Subscribed!
Learned a lot from this. Thank you so much Kyle 🙏🏼
You're welcome!
Amazing tutorial, as special the approach to trigger the axios function via IntersectionObserver instead of div.scrollHeight.
Thank you so much! I was struggling with window object so long and finally your video helped me!
ruclips.net/video/c0nKjMnDfG4/видео.html&ab_channel=Front-EndHacks
Watch Infinite Scroll Video here in Hindi
This react lecture is AMAZING... Thanks from Korea.
This is a great tutorial, straight to the point and clear. Thank you, Kyle!
Amazing! Thank you very much, I thought it would be harder to make something like this.
Also THANKS because I finally got how to make a custom hook, I was having some struggles to get it.
Thank you so much for this tutorial, it literally helped me pass in a interview test 👏
thanks!! used your pagination api with this, tweaked it a little as i'm using sequelize and it works great.
I am really impressed by this tutorial, it helped me a lot in my current react project, thank you!
Your tutorials are incredible! It's so much great information in such a concise presentation.
I. You are awesome. This video is amazing. You just went straight to the point and your language was very clear. Thanks for sharing this content.
Thank you so much! None of the other solutions worked for me except this!
The best tutorial I've ever seen
I'm tried to use infinite scrolling library but it not looking good.
Your video had save my life it working great and smooth, Thanks
Never saw any better explaination than this, thank you ..
Just used this at work. Thank you Kyle!
Thanks for the tutorial. This is probably the best, most straightforward tutorial
Really good approach, dude your video helped me a lot to finish my project at work, Thank you so much
Thank you for making such an understandable and useful lessons! You're really great🙏💛
you've a better solution than using scroll position broo, good job!!
its totally amazing. i dont know about intersection observer so was a bit confused there but the video was mind blowing. Thanks for explaining the idea behind the infinite scroll
Intersection Observer is a bit complex, but it makes doing things like infinite scrolling so much easier.
@@WebDevSimplified yes.. absolutely correct
The intersectionObserver is awesome!! so much more practical!
Cool . Got my all doubt cleared. Nice work
A very great tutorial man.
your videos are awesome-- thank you!
also, happy new year
There is one serious situation custom hooks can land into is when the arguments change, the useEffect inside hook is not called synchoronously, in fact it is called asynchronously whenever React wants, therefore, the very first render after the change of the arguments, hook will still return the stale data (in this case the books because of useState). I land into this issue when I was creating my useLocalStorage which takes a key. And when I change the key it still returns data for the old key. This scenario is well taken care by useSWR hook, the moment the API URL changes the data returned is different. Can you make a video regarding these advanced patterns in REACT sometime?. That would be wonderful!
incredible bro i appreciate this🙌 kind of content
This tutorial is amazing! Thank you very much for making it simpler!
Great explanation! Thanks Kyle!
Awesome tutorial mate! I suggest including "Custom React Hooks" in your title. I was actually pleasantly surprised that this tutorial was going to include custom hooks. If I had saw that in the title, I would have clicked on it way earlier since React Hooks is the hot thing that everyone should be learning now. Furthermore, now that I've saved this to my React playlist, I still won't know that it includes custom hooks when I scan through all the video titles.
Thanks man. A much needed tutorial for me...
Nice video, worked like a charm
Thanks for this man, exactly what I was looking for, now I can create what I wanted. THANKSSSSSSSSSSSSSS
Thanks a lot Kyle. All of your videos are top notch..
Very clever implementation!
Thank you for this tutorial! I got something similar workign, I just wanted the "isVisible" for one of my elements to show up.
I think this video is a little too long, and getting the custom hook created is a little bit of a side job for getting infinite scrolling, and I would have preferred just getting the "isVisible" working, and then going from there.
That being said, thanks for the info, your tutorials are always at a good pace, and I like that you've included the source code!
Just a side note, you can also use Debounce Component to have delay when the user stops typing. Anyway, Great job! thanks for this!
Very true. For this small use case it isn't really a big deal, but in a larger application this could save a lot of performance. Thanks for the tip.
@@WebDevSimplified can you point me to some resource for this"debounce"? Thanks
@@ManishKarki you can search for react-debounce-input
@@ManishKarki Just do a Google search for React debounce. Essentially all it is, is delaying the axios request.
so much useful info in 25 mins 😄 thanks!
Very very straightforward, keep the good work and thanks!
Great Tutorial... Helped a lot
Amazing video. You have made a complex thing look so easy. Keep up the great work!!
Thank you!
ruclips.net/video/c0nKjMnDfG4/видео.html&ab_channel=Front-EndHacks
Watch Infinite Scroll Video here in Hindi
Didn't realize so little code was required for this. I'm too used to using libraries and I'm not aware of what Web APIs there are. Going to put an effort to learning more of these things and getting comfortable with web APIs like Intersection observers and setting it all up with refs and callbacks
24k pure gold. Thank you so much!
Thanks a lot for the video🙏. Finally understood infinite scrolling.👍
Hey Kyle, thanks for the amazing tutorial, appreciate your work. I know this is an older video but had a quick question if you ever had the chance to read this, I can't figure out why the function inside the useCallback() where you defined the intersection observer get's called 4 times each time an intersection is observed. Best.
Its being called twice, the first time you feed the target (node ) to the observer and the second when the target intersects with its intersection root (the scrollable div container)
This is so easy to use and does help a lot! Thank you for the video!
Nice and clean tutorial! Very good explained!
Love Your Videos bro 👏👏
Awesome explanation 👌🤩
thanks, great tutorial. prob one of the best i ever watch
Awesome tutorial!! thanks for this high quality work!
thanks dude, u save my job. button like for u
nice tutorial , clear explanation , thanks bro
I learned a lot from this video. Thank you, Kyle.
You are very welcome
Very simple explanation. thanks alot
1000 likes from my side, Brother.
Awesome. Just what I was looking for. I used it in photo grid and full screen view in my app. Thanks
Thank man!! It was very simple to implement and add to the project.
Thank you for this amazing video! My project was a little different but I managed to make it work in a short amount of time.
ruclips.net/video/c0nKjMnDfG4/видео.html&ab_channel=Front-EndHacks
Watch Infinite Scroll Video here in Hindi
The best tutorial in youtube!!!
Really appreciate your work, simplest of all
ruclips.net/video/c0nKjMnDfG4/видео.html&ab_channel=Front-EndHacks
Watch Infinite Scroll Video here in Hindi
thanks bro, very useful :)
Wow, infinite scrolling was simplified many thanks, your explanations help me grok
Thanks for the great content!
wow you just taught us to make a node_module. Thank you so much
Nailed it. Thanks for the Topic
Very Useful Thank you saved my day
This is very helpful. Thank you.
This is a great example - thanks
Thank you so much, useful❤
Thank You. :) Works like a charm
cancelToken working?
Great video, good job!
You Solved My Problem Thanks Sir
Hi Kyle, thank you for sharing the video. 17: 05 to 17: 46 min saved me. I never used two userEffect before, one to clean the state another to fetch data until I watched your video.
I am implementing Cursor relay pagination. I had an issue about clearing old data. Whenever react-route changes I could get old data and new data repeatedly. I 've fixed the issue after 2 days struggling with your help.
God bless you brother.
why is openlibrary.org/search.json empty?
Very good tutorial, but what if we don't use axios, instead we are using vanilla xmlhttprequest, how do we do throttling effect in this circumstances ?
O boy !! That was excellent 👍👌
Thank you!
Amazing content!
Thanks a lot!
Using the ref on the children will force them to re-render when they're not the last item in the array, so maybe is better to use a the ref on a footer or something to observe the IntersectionObserver.
And use useEffect to have the same functionality.
Hey Kyle, what advantage did useCallback have here over a regular function, since it's using a dependency array anyway? Thanks for the video!
Really good content kyle, please make video on lazy loading and interceptor in react (:
great tutorial, thanks!
Thanks a lot. Great explanation!!
A react native tutorial on this would also be awesome. Currently building an app with native.
I don't like mobile development so there probably won't be much if any React Native on my channel.
Great! I want to highlight that you keep adding new items to DOM, which will make DOM heavy. In this approach, We might have a large number of elements. How can we solve this issue? Is there any approach where we can maintain a specific set of items? No matter how long the list is.
Great lesson. Thank you!
Magnificent video 👏👏👏
When should this infinite scroll be used vs manual pagination?
Litterally you have an example on RUclips check your notification bell
Hi, first of all, owsm breakdown of the code... loved it, understood it.
1 QUERY, after loading 1 or 2 more page if the error occur, then along with Error... , Loading... is also present.
Can you tell how to remove the loader if the error occurs?
why is openlibrary.org/search.json empty?