I need to implement infinite scrolling in a react app, while my data is huge and the use might keep on scrolling and scrolling for a long time.
All the infinite scrolling solutions that I've found only handle adding the data to the table whole scrolling. But I need to also remove data from the DOM to prevent the app from slowing due to tens of thousands of rows being potentially loaded after some time on the app (think social media feed). I also don't want to keep all the data in the memory and I need to clean old data while scrolling (up and down).
So basically what I need to do:
Does anyone know of such a solution? Any recommendations on how to tackle this if I need to build from scratch?
Thanks!
1. Use react-infinite-scroll-component.
Follow instructions in documentation.
You can see basic example here. Here initially array have 20 elements and fetchMoreData function concatinate 20 more elements to it.
Basically you are concatinating, next elements in in array and adding them over, this is the concept of infinite-scroll.
For furthur references, link1, link2.
Or
2. You can implement you custom scrolling as well, like this