How I load lots of data in my React application

  Рет қаралды 30,647

LifeLoveAndMonads

LifeLoveAndMonads

Күн бұрын

In my React application I use infinite scrolling instead of pagination to show users lots of data and in this video I show how exactly I do that, first giving a brief overview of the difference between two techniques and then demonstrating my React frontend and my ExpressJS/MongoDB backend.
UPDATE: In the video I say "virtualisation" but that is not correct term, since probably more appropriate one is infinite scrolling or lazy loading, or something along that line.
You can reach out:
Discord: / discord

Пікірлер: 53
@memeproductions4182
@memeproductions4182 Ай бұрын
Infinite scrolling even if used together with virtualization still has its limits, for example if you were to scroll to the end of a very large list you would still have all the elements in memory, if they are a lot they could even lead to the application crashing
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
I agree, thats a very good take. Since virtualisation takes care of elements unmounting, but you are correct that, especially in the shown example, the data itself will be in memory. But I guess when you are measurably can end up in that situation you would also implement data off-loading.
@memeproductions4182
@memeproductions4182 Ай бұрын
​@@LifeLoveAndMonadsyeah, I don't envy the guy who would have to implement that though lol
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
I honestly don't think that it is THAT hard, but surely there are plenty of nuances and edge cases. But that is true for any serious application out there. But since most places where virtualisation is present are rather big companies: Discord, Facebook, YT, etc, they will find a bunch of smart people to solve those issues :)
@jamjam3448
@jamjam3448 Ай бұрын
What if you use intersection observer to unmount when it's not in view.
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
you can use intersection observer to unmount things that are not in the view, I believe, but it was more about making sure you do not build too much data in memory I guess, but you can certainly figure something out, like I have said, I do not think it is that much of a problem, as long as you know exact requirements and clear formulation of a problem
@anj000
@anj000 Ай бұрын
For most cases do not use infinite scrolling. Couple of years ago there was a trend to use it everywhere because it was rather new and fancy, but it is pain in the as for the users. And it can cause accessibility, seo and performance issues.
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
Valuable points!
@ehza
@ehza Ай бұрын
Nice. Keep it up.
@ManuelBorges1979
@ManuelBorges1979 Ай бұрын
I liked the video. Good job. 👏🏼 I subscribed.
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
Thank you!
@ShighetariVlogs
@ShighetariVlogs Ай бұрын
I like your content thank you for sharing 🎉
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
Thank you for watching :)
@Alex.Shalda
@Alex.Shalda Ай бұрын
awesome video
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
Thanks mate!
@user-qr4jf4tv2x
@user-qr4jf4tv2x Ай бұрын
i like to put pagination on an api. load everything needed then slice it up and store it in s3
@federicoreina7732
@federicoreina7732 Ай бұрын
If you have enough data in your db (and supposing the user scrolls a lot) I think your performance will degrade over time as the DB needs to traverse all the elements you are skipping. For this case having a search token that keeps account of the search position is a possible solution
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
Thanks for the advice!
@Rodrig79863
@Rodrig79863 Ай бұрын
Clicked cause of the thumbnail 👍
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
We call it psychology.
@VuNguyen-yj5wi
@VuNguyen-yj5wi Ай бұрын
How about a case when you scroll down to get next data for next page from server, but there is a some records whichs were inserted before you scroll down, therefore the datas for next page will include records whichs were loaded before
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
Thats exactly what happened behind the scenes of this video :) But because I think something was every now and then happening twice, so I have handled that in my "merge" data function. But you can always find more sophisticated way. And of course you can try to make sure that each page contains unique data. I can see that sometimes its not up to you, since for example while you were requesting for data, new items were added and concept of "pages" shifted. In that case you can try to do something like firebase does, when they return pages they are sort of like linked lists of chunks of data, since data should be ordered on the backend before pagination and pagination itself has to be a bit more complicated that just skip/limit.
@teujorge
@teujorge Ай бұрын
use a "cursor"... say you fetch 10 items. you get the ID of the last item and that becomes your cursor. your next fetch will be the next 10 items after the cursor. you may also need to sort your data...
@twitchizle
@twitchizle Ай бұрын
Just get the next 10 record after the id of last record.
@sthernito
@sthernito Ай бұрын
This is a really interesting topic and great to see how to implement Virtualization, but at the end it depends entirely in the project, there will be cases where pagination is a better experience for the users and cases where Virtualization could be, just remember the rule, you are not your user.
@arshiagholami7611
@arshiagholami7611 Ай бұрын
use an index 🎉
@karansharma-fv2dd
@karansharma-fv2dd Ай бұрын
Can anyone please help how to retain CTRL + F functionality of the browser as a normal user you would expect that functionality to work but due to this. it will break.
@ChristopherJamesCalo
@ChristopherJamesCalo Ай бұрын
There's no way to Ctrl F over content that is not in the DOM. But you could try building a filtering search box that searches over all records, whether they be in memory (but not in the DOM) or on the server. Then what you do to update the list in the DOM is up to you.
@dgcp354
@dgcp354 Ай бұрын
add an event on button push for CTRL that focus on search input
@ducklingzpl46u36
@ducklingzpl46u36 Ай бұрын
Can you make more performance videos for react. Would love you. Already subscribed.
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
Thanks mate! In full honesty I would not consider this current video has anything to do with performance, only from the perspective that we do not load all data at once and exploring, sort, two path we can take to achieve that. So no promises, but hopefully it will be more videos to like :)
@FrontendNerd-lg3oh
@FrontendNerd-lg3oh 2 ай бұрын
Video is neat
@LifeLoveAndMonads
@LifeLoveAndMonads 2 ай бұрын
Thank you!
@rawallon
@rawallon Ай бұрын
No, you're neat
@jobasti
@jobasti Ай бұрын
Why is this called "virtualization" and not doom-scrolling, endless-scrolling or lazy-loading? Virtualization is a totally different thing and well known since decades .... i dont get it ... please help.
@tedchirvasiu
@tedchirvasiu Ай бұрын
Everything needs a fancy name to stay relevant.
@jobasti
@jobasti Ай бұрын
@@tedchirvasiu Well if Doom-Scrolling isnt fancy i dont know what is xD
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
never heard that term! I will call it Doom-scrolling from now on :)
@jobasti
@jobasti Ай бұрын
@@LifeLoveAndMonads Facebok, Twitter and almost every "community" site uses that since forever. :)
@titbarros
@titbarros Ай бұрын
Virtualization is not necessary infinite. You might be virtualizing a well known number of items. And is not necessarily scroll either. Think diagrams.
@Mashwishi
@Mashwishi Ай бұрын
Is this good for like social media web apps ?
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
I think it is good for any case where you don't want pagination for some reason - Messenger, Telegram or Discord chat, social media apps like Facebook, Reddit, etc.
@backupmemories897
@backupmemories897 Ай бұрын
let me introduce you to virtual scrolling xD you can render 10m list and it wont lag because it only gonna show u list that fits on the container. in any direction.. if u look at dom u gonna see the list are being deleted and inserted dynamically.. instead of 10m divs on the inspect element u gonna only see maybe 20-30 items depends on your item height.. and how much of that fits on the container.
@blackwatch2150
@blackwatch2150 Ай бұрын
Ohh, means virtualization won't affect performance.
@jma42
@jma42 Ай бұрын
basically that is still in some way, a form of caching, which is another can full of worms
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
In full honesty, I do not see a connection with caching, but implementing a proper list virtualisation can be not super easy. In my case and in the video its kinda a very simple case.
@aer1th621
@aer1th621 Ай бұрын
can i have github repos?
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
sure, github.com/PompolutZ/wuclub_monorepo
@IvanAndrieiev
@IvanAndrieiev 2 ай бұрын
@LifeLoveAndMonads
@LifeLoveAndMonads 2 ай бұрын
Thank you!
@towu
@towu Ай бұрын
Nice stuff! Do you have a discord server?
@LifeLoveAndMonads
@LifeLoveAndMonads Ай бұрын
Not yet, never had a reason to have one :) And I have never used Twitter :) UPD: Now I have - discord.gg/cs9uKmCZ
When YOUR tech lead is wrong about React hooks
14:45
LifeLoveAndMonads
Рет қаралды 308
Efficiently Render 100,000 Rows in React
16:41
Cosden Solutions
Рет қаралды 14 М.
Эта Мама Испортила Гендер-Пати 😂
00:40
Глеб Рандалайнен
Рет қаралды 9 МЛН
О, сосисочки! (Или корейская уличная еда?)
00:32
Кушать Хочу
Рет қаралды 2,7 МЛН
одни дома // EVA mash @TweetvilleCartoon
01:00
EVA mash
Рет қаралды 6 МЛН
SHE WANTED CHIPS, BUT SHE GOT CARROTS 🤣🥕
00:19
OKUNJATA
Рет қаралды 3,1 МЛН
Are You In A React Cult?
13:27
Jack Herrington
Рет қаралды 28 М.
Finally Fix Your Issues With JS/React Memory Management 😤
20:13
Jack Herrington
Рет қаралды 75 М.
OpenAI "SHOCKED" Everyone! Voice, Vision, & Free?!
8:58
Theoretically Media
Рет қаралды 8 М.
Философия Unsafe Rust
22:35
Bitωise
Рет қаралды 4,4 М.
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 23 М.
So You Think You Know Git - FOSDEM 2024
47:00
GitButler
Рет қаралды 911 М.
If this ships, it will change javascript forever
25:54
Theo - t3․gg
Рет қаралды 182 М.
Goodbye, useEffect - David Khourshid
29:59
BeJS
Рет қаралды 492 М.
Web Developer Roadmap (2024) - Everything is Changing
25:02
ByteGrad
Рет қаралды 227 М.
Вы поможете украсть ваш iPhone
0:56
Romancev768
Рет қаралды 385 М.
Главная проблема iPad Pro M4 OLED!
13:04
THE ROCO
Рет қаралды 47 М.
Any Sound & Call Recording Option Amazing Keypad Mobile 📱
0:48
Tech Official
Рет қаралды 325 М.
What % of charge do you have on phone?🔋
0:11
Diana Belitskay
Рет қаралды 241 М.