Infinite Scrolling With React - Tutorial

  Рет қаралды 367,984

Web Dev Simplified

Web Dev Simplified

Күн бұрын

Пікірлер
@jefffideler8046
@jefffideler8046 4 жыл бұрын
Gotta say...this is probably the best, most straightforward tutorial I've ever seen!
@Mike37373
@Mike37373 4 жыл бұрын
why is openlibrary.org/search.json empty?
@jefffideler8046
@jefffideler8046 4 жыл бұрын
@@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
@serhendiefendi
@serhendiefendi 4 жыл бұрын
i agree
@xanderav
@xanderav 4 жыл бұрын
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.
@irasanchez1265
@irasanchez1265 3 жыл бұрын
No need to apologize for your English. it was understandable.
@nishantmogha7679
@nishantmogha7679 3 жыл бұрын
Or you can just use the array, [] is falsy.
@limitless9483
@limitless9483 3 жыл бұрын
@@nishantmogha7679 array [] and {} are truthy brah
@limitless9483
@limitless9483 3 жыл бұрын
Also to make sure the app won't crash when array is null use optional chaining like myArr?.length
@xxxyy7452
@xxxyy7452 2 жыл бұрын
You can do that, but sometimes clearly code better than clever code
@shivaskanthan6144
@shivaskanthan6144 3 ай бұрын
4 years later and this still works like a gem, Kudos to you!
@johnbox5540
@johnbox5540 4 жыл бұрын
awesome video. infinite scrolling starts at 17:50
@toaninh2668
@toaninh2668 2 жыл бұрын
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
@whereismyjuliet
@whereismyjuliet 4 жыл бұрын
Amazing tutorial, as special the approach to trigger the axios function via IntersectionObserver instead of div.scrollHeight.
@sahaneakanayaka3394
@sahaneakanayaka3394 2 жыл бұрын
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 😍😍
@magicfibre
@magicfibre 2 жыл бұрын
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.
@CaratBoo1D
@CaratBoo1D Жыл бұрын
Wonderful explanation!!
@JeanGray218
@JeanGray218 Жыл бұрын
this literally just happened in class a few minutes ago in this example our TA was showing us...thank you now I understand why
@manavdixit3355
@manavdixit3355 Жыл бұрын
Why can't we just create an reference using useRef and pass it to the component. Then Handel the intersection observer without a function.
@kavyar8579
@kavyar8579 Жыл бұрын
Great explanation
@CesarZaitoun
@CesarZaitoun 4 ай бұрын
Thanks for explaining that, this is the only section in the video that I needed more explanation on
@rajapavithraselvaraj5937
@rajapavithraselvaraj5937 2 жыл бұрын
I really have to say.. this was the best, clear, very staright forward tutorial. AWESOME
@fluntimes
@fluntimes 4 жыл бұрын
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.
@aryavats5403
@aryavats5403 Жыл бұрын
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!
@akarshsrivastava8890
@akarshsrivastava8890 3 жыл бұрын
Kyle, you are great. Never found a tutor explaining such complex topics so easily. 😊
@acedecastro83
@acedecastro83 5 жыл бұрын
Learned a lot from this. Thank you so much Kyle 🙏🏼
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
You're welcome!
@Doom_C
@Doom_C 5 жыл бұрын
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!
@uszeyboi
@uszeyboi 4 жыл бұрын
Thank you so much! I was struggling with window object so long and finally your video helped me!
@frontendHacks
@frontendHacks 2 жыл бұрын
kzbin.info/www/bejne/mWHRfJ2Do6mZfZY&ab_channel=Front-EndHacks Watch Infinite Scroll Video here in Hindi
@rizqyhbb
@rizqyhbb 2 жыл бұрын
just from this video I have learned so many things, mainly the useRef and useCallback. thankyou
@봄여율-u9f
@봄여율-u9f 3 жыл бұрын
This react lecture is AMAZING... Thanks from Korea.
@supreechajaijumpa4656
@supreechajaijumpa4656 2 жыл бұрын
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
@eternl_sunshine22
@eternl_sunshine22 10 ай бұрын
thanks!! used your pagination api with this, tweaked it a little as i'm using sequelize and it works great.
@Rodo1802
@Rodo1802 Жыл бұрын
This is a great tutorial, straight to the point and clear. Thank you, Kyle!
@LinkSake
@LinkSake 5 жыл бұрын
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.
@sendashish
@sendashish 2 жыл бұрын
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!
@sergiodfm
@sergiodfm 4 жыл бұрын
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.
@nalladileepreddy1436
@nalladileepreddy1436 3 жыл бұрын
Never saw any better explaination than this, thank you ..
@isaacpriestley
@isaacpriestley Жыл бұрын
Your tutorials are incredible! It's so much great information in such a concise presentation.
@brunamarques580
@brunamarques580 Жыл бұрын
Thank you so much for this tutorial, it literally helped me pass in a interview test 👏
@usamatahir6413
@usamatahir6413 3 жыл бұрын
Thanks for the tutorial. This is probably the best, most straightforward tutorial
@mohammadaldibes6879
@mohammadaldibes6879 2 жыл бұрын
The best tutorial I've ever seen
@koladeleolaitan
@koladeleolaitan 2 жыл бұрын
Just used this at work. Thank you Kyle!
@MaxAigner
@MaxAigner 2 жыл бұрын
I am really impressed by this tutorial, it helped me a lot in my current react project, thank you!
@romihasan380
@romihasan380 3 жыл бұрын
you've a better solution than using scroll position broo, good job!!
@RizaHariati
@RizaHariati 3 жыл бұрын
The intersectionObserver is awesome!! so much more practical!
@jrs_devs
@jrs_devs 2 жыл бұрын
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.
@brindch8372
@brindch8372 5 жыл бұрын
Just a side note, you can also use Debounce Component to have delay when the user stops typing. Anyway, Great job! thanks for this!
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
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.
@ManishKarki
@ManishKarki 5 жыл бұрын
@@WebDevSimplified can you point me to some resource for this"debounce"? Thanks
@brindch8372
@brindch8372 5 жыл бұрын
@@ManishKarki you can search for react-debounce-input
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
@@ManishKarki Just do a Google search for React debounce. Essentially all it is, is delaying the axios request.
@ismoilshokirov
@ismoilshokirov 3 жыл бұрын
Really good approach, dude your video helped me a lot to finish my project at work, Thank you so much
@NikhilAdiga
@NikhilAdiga 3 жыл бұрын
Thank you so much! None of the other solutions worked for me except this!
@parasarora5869
@parasarora5869 5 жыл бұрын
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
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
Intersection Observer is a bit complex, but it makes doing things like infinite scrolling so much easier.
@parasarora5869
@parasarora5869 5 жыл бұрын
@@WebDevSimplified yes.. absolutely correct
@aronhegedus
@aronhegedus 2 жыл бұрын
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!
@АлинаКуракина-в9у
@АлинаКуракина-в9у 9 ай бұрын
Thank you for making such an understandable and useful lessons! You're really great🙏💛
@baileysli6235
@baileysli6235 2 жыл бұрын
5:24 - use https if you have problems
@viratkohli-jr6md
@viratkohli-jr6md 3 жыл бұрын
Cool . Got my all doubt cleared. Nice work
@jairocket
@jairocket 3 жыл бұрын
This tutorial is amazing! Thank you very much for making it simpler!
@Nil-js4bf
@Nil-js4bf 2 жыл бұрын
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
@kingsleyakindele5389
@kingsleyakindele5389 3 жыл бұрын
A very great tutorial man.
@bahtiyarahmidi2938
@bahtiyarahmidi2938 3 жыл бұрын
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 ?
@razzsawhoney2818
@razzsawhoney2818 4 жыл бұрын
Thanks man. A much needed tutorial for me...
@anshshrivastava9107
@anshshrivastava9107 3 жыл бұрын
Thanks for this man, exactly what I was looking for, now I can create what I wanted. THANKSSSSSSSSSSSSSS
@itsatimemachine
@itsatimemachine 3 жыл бұрын
your videos are awesome-- thank you! also, happy new year
@faris.abuali
@faris.abuali Жыл бұрын
Great explanation! Thanks Kyle!
@ankitmehrotra8519
@ankitmehrotra8519 4 жыл бұрын
Thanks a lot Kyle. All of your videos are top notch..
@mayurborse1745
@mayurborse1745 4 жыл бұрын
Awesome. Just what I was looking for. I used it in photo grid and full screen view in my app. Thanks
@DieterWiesflecker
@DieterWiesflecker 3 жыл бұрын
Very very straightforward, keep the good work and thanks!
@jhmesseroux
@jhmesseroux 2 жыл бұрын
incredible bro i appreciate this🙌 kind of content
@chexter-wang
@chexter-wang 3 жыл бұрын
This is so easy to use and does help a lot! Thank you for the video!
@amitpareek8905
@amitpareek8905 4 жыл бұрын
Amazing video. You have made a complex thing look so easy. Keep up the great work!! Thank you!
@frontendHacks
@frontendHacks 2 жыл бұрын
kzbin.info/www/bejne/mWHRfJ2Do6mZfZY&ab_channel=Front-EndHacks Watch Infinite Scroll Video here in Hindi
@djmilen4o
@djmilen4o 4 жыл бұрын
Nice and clean tutorial! Very good explained!
@AbhishekBijalwanGaz
@AbhishekBijalwanGaz 4 жыл бұрын
1000 likes from my side, Brother.
@invictuz4803
@invictuz4803 4 жыл бұрын
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.
@mcy93w
@mcy93w 3 жыл бұрын
24k pure gold. Thank you so much!
@shivrajnag12
@shivrajnag12 3 жыл бұрын
How to deal with the scenerio when each item has a delete button along side it and the user can delete item while scrolling, then data will change at the backend(The data will shift to previous page and I will not get the correct no of data for scrolled page ) I hope you understood what I mean to say
@waynes9744
@waynes9744 5 жыл бұрын
I learned a lot from this video. Thank you, Kyle.
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
You are very welcome
@kumardeepak260
@kumardeepak260 4 жыл бұрын
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?
@Mike37373
@Mike37373 4 жыл бұрын
why is openlibrary.org/search.json empty?
@mellocamilo
@mellocamilo 3 жыл бұрын
Awesome tutorial!! thanks for this high quality work!
@Andy801_dawless_music
@Andy801_dawless_music 4 жыл бұрын
so much useful info in 25 mins 😄 thanks!
@ashokumarkuppuram6685
@ashokumarkuppuram6685 3 жыл бұрын
Thanks very much! I developed my app with infinite scrolling. One issue I am facing is that there are multiple setState operations say setHasMore, setLoading along with setData which is causing multiple render operation.If our table is heavy, it looks little burden to the table. Please advice. Thanks.
@yassinerassy6840
@yassinerassy6840 2 жыл бұрын
Use usereducer hook instead or one object in which You puts all the data you have with usestate
@lexternal
@lexternal 2 жыл бұрын
thanks, great tutorial. prob one of the best i ever watch
@rva3674
@rva3674 4 жыл бұрын
The best tutorial in youtube!!!
@marcusmaiialima
@marcusmaiialima 3 жыл бұрын
Thank man!! It was very simple to implement and add to the project.
@ashishkumawat6110
@ashishkumawat6110 Жыл бұрын
Very clever implementation!
@mohammadusman9701
@mohammadusman9701 3 жыл бұрын
Hi, I have a doubt - what if when our page loads for the first time, we want to show the list of books with infinite scroll , and later when the query occurs we can filter the books . Any idea how can we achieve that
@KarahannAe
@KarahannAe 3 жыл бұрын
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.
@frontendHacks
@frontendHacks 2 жыл бұрын
kzbin.info/www/bejne/mWHRfJ2Do6mZfZY&ab_channel=Front-EndHacks Watch Infinite Scroll Video here in Hindi
@TiberiusGracchi
@TiberiusGracchi 2 жыл бұрын
Very good information, especially the part about using useCallback instead of ref. I was just wondering how to grab the last node.
@kat802
@kat802 3 жыл бұрын
thanks dude, u save my job. button like for u
@md.akib5124
@md.akib5124 5 жыл бұрын
wow you just taught us to make a node_module. Thank you so much
@alext8593
@alext8593 3 жыл бұрын
Hi, nice video! Could someone kindly explain to me why Kyle decided to use the "useCallback()" hook? Is it because recreating the callback that initiates the Intersection Observer instance etc. is expensive/intense and thus it makes sense not to recreate it every time? Thanks x
@soultouchingsongs
@soultouchingsongs 4 жыл бұрын
Thanks a lot for the video🙏. Finally understood infinite scrolling.👍
@HostDotPromo
@HostDotPromo 5 жыл бұрын
A react native tutorial on this would also be awesome. Currently building an app with native.
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
I don't like mobile development so there probably won't be much if any React Native on my channel.
@irvanhardyanto7038
@irvanhardyanto7038 5 ай бұрын
Nice video, worked like a charm
@sonesay
@sonesay 2 жыл бұрын
Hi, I have one question. How do I cause the api call or fire without the onchange handler? Like I want it load my data on initial load and then any subsequent search types would continue to work as normal?
@meetshah4432
@meetshah4432 3 жыл бұрын
Actual stuff starts from 17:50 guys. You can skip to that.
@chronotriggered204
@chronotriggered204 4 жыл бұрын
Wow, infinite scrolling was simplified many thanks, your explanations help me grok
@akshayjadhav2418
@akshayjadhav2418 4 жыл бұрын
Really good content kyle, please make video on lazy loading and interceptor in react (:
@SanjayYadav-ur4qj
@SanjayYadav-ur4qj 6 ай бұрын
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.
@bipinnamburu9820
@bipinnamburu9820 7 ай бұрын
Hey,why do we need to store previous books initially while just fetching all the books according to the string?
@gautamv2046
@gautamv2046 4 жыл бұрын
Really appreciate your work, simplest of all
@frontendHacks
@frontendHacks 2 жыл бұрын
kzbin.info/www/bejne/mWHRfJ2Do6mZfZY&ab_channel=Front-EndHacks Watch Infinite Scroll Video here in Hindi
@dijkstra5952
@dijkstra5952 3 жыл бұрын
Nice tutorial. Although it's more correct semantically to use useEffect for attaching and disconnecting an observer on the last visible node rather than using useCallback like you did. Thanks for your videos!
@quoccuong1733
@quoccuong1733 3 жыл бұрын
Is there a difference though. Ive doing it the useEffect way but wonder if 2 methods differ in any way
@yassinerassy6840
@yassinerassy6840 2 жыл бұрын
Can you provide more details why ?
@rideforworld
@rideforworld 4 жыл бұрын
congrats for your engagement!
@riankrishandi
@riankrishandi 3 жыл бұрын
nice tutorial , clear explanation , thanks bro
@BhushanDhage
@BhushanDhage 4 жыл бұрын
Awesome explanation 👌🤩
@brinascode980
@brinascode980 4 жыл бұрын
Hey Kyle, what advantage did useCallback have here over a regular function, since it's using a dependency array anyway? Thanks for the video!
@kestutisgimbutas5314
@kestutisgimbutas5314 4 жыл бұрын
My page gets re-rendered every single time I change state and after re-rendering I am placed in the top of the page. What am I doing wrong?
@akash.serene
@akash.serene 3 жыл бұрын
My first guess is you are not appending the state values in the prev state. Probably you are overwriting your state in every call
@yorkwebsolution8986
@yorkwebsolution8986 4 жыл бұрын
Very simple explanation. thanks alot
@AjithAbinashSS
@AjithAbinashSS Жыл бұрын
Great Tutorial... Helped a lot
@niyongaboeric
@niyongaboeric 4 жыл бұрын
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.
@Mike37373
@Mike37373 4 жыл бұрын
why is openlibrary.org/search.json empty?
@dipankarmaikap
@dipankarmaikap 3 жыл бұрын
When implementing this it keeps auto firing once reached to the bottom of the page but in your example its keeping the scroll position same and appending the data bellow. Any idea why this is happening.? Note* If i manually scroll up it stops working and again starts auto firing when scroll to the button.
@sebastianalvarez3053
@sebastianalvarez3053 3 жыл бұрын
set "overflow-anchor: none; " in css. Look at the example of the chat in this link css-tricks.com/almanac/properties/o/overflow-anchor/
@shahzaibriaz6552
@shahzaibriaz6552 3 жыл бұрын
Please explain a little bit about intersectionObserver api and how did you identity that you've to use "useRef" hook with Intersection Observer API
@navead30
@navead30 4 жыл бұрын
Nice tutorial. This works smoothly for text based results. But it will struggle to render list of complex React components when list becomes huge. Can we also have a React window tutorial
@bobkazamakis5169
@bobkazamakis5169 3 жыл бұрын
what do you mean by that?
@engineerscodes
@engineerscodes 2 жыл бұрын
how to prevent multiple axios requests on infinite scroll ?
@hakanaki
@hakanaki 3 жыл бұрын
Love Your Videos bro 👏👏
@jivanmainali1742
@jivanmainali1742 4 жыл бұрын
When we have millions of element do we really do map to show individual list items
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 492 М.
Speed Up Your React Apps With Code Splitting
16:50
Web Dev Simplified
Рет қаралды 395 М.
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 63 МЛН
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 29 МЛН
Infinite Scrolling in React using Intersection Observer
29:35
Frontend Interview Pro
Рет қаралды 2,1 М.
React Intersection Observer (scroll + lazy-load  картинок)
22:10
Infinite Pagination Component With React Query
14:58
Cosden Solutions
Рет қаралды 25 М.
You Don't Need JavaScript For This - CSS ONLY Infinite Scroll
23:35
Slaying The Dragon
Рет қаралды 150 М.
How To Handle Permissions Like A Senior Dev
36:39
Web Dev Simplified
Рет қаралды 283 М.
Top 6 React Hook Mistakes Beginners Make
21:18
Web Dev Simplified
Рет қаралды 583 М.
Create an infinite horizontal scroll animation
32:01
Kevin Powell
Рет қаралды 218 М.
How to build a REST API with Node js & Express
58:40
Programming with Mosh
Рет қаралды 1,8 МЛН
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН