A
A
Alexander Wolf2016-07-04 14:47:41
JavaScript
Alexander Wolf, 2016-07-04 14:47:41

React and very long lists. How to make it "not lag"?

Good day, colleagues! We have a list of unlimited length (in the future). At the moment the list consists of 26k lines. The whole thing lags wildly when scrolling the wheel. Pagination isn't quite right. I would like to do something like infinity scroll, but here's the dilemma: having screwed it up to the end, the user will lag everything just as it lags before.
Looking at the wall, for example, on VKontakte, they implement this by removing old entries from the DOM, and a specially trained DIV takes their height.
In order not to make such a bike, tell me, please, are there any ready-made solutions?
PS: if something is not clear, write in the comments, I will explain.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mikhail Osher, 2016-07-04
@mannaro

https://github.com/bvaughn/react-virtualized

S
Sergey, 2016-07-04
Protko @Fesor

it's called "virtual scroll"
Here's the finished bike (and there are 4 more but they have fewer stars)
developerdizzle.github.io/react-virtual-list - here's an example with 100K records. Most of the ones I've seen are designed only for cases where we always know the height of the list element in advance. In VKontakte or there, LinkedIns are a little trickier, where they try to pre-render the list in advance, and it also helps them that the data is not loaded immediately (not immediately 100K items, but in pieces of 100 pieces, for example). This gives more scope for action.

E
Eugene, 2016-07-04
@zolt85

There are no ready made solutions. Everyone cycles in their own way, but it all comes down to one thing - there are only visible lines in the DOM. Those. when scrolling down, the top lines are removed, and vice versa when scrolling up. Then display problems begin with very fast scrolling back and forth, in general, a creative task, go for it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question