Hello folks,
Few days back I came across the use-case of infinite scroll in React. For this, I used Intersection Observer and found different way...
For further actions, you may consider blocking this person and/or reporting abuse
Why have to used this ref={setLastElement} ? isn't it supposed to be ref={observer} ?
Read about callback refs for this.
This is great, do you have a solution for infinite scroll + virtualisation? That's the holy grail I haven't been able to implement well
A lot of React libs doing that out there Jai Sandhu
Haven't found a good one that caters for different height cells and infinite scrolling
Hi Jai. This solution has an interesting take on different height cells in a virtualised list. dev.to/miketalbot/react-virtual-wi....
Oooh wow thanks that looks awesome!
Your arcticle helped a lot. Thanks for indetailed explanation. I have some suggestion.
There are 2 ways:
with 1st we need calculate the last ele, with 2nd it becomes much cleaner and simpler.
Adding YT link for those who want video explanation.
https://www.youtube.com/watch?v=8kLOvs1prEM&t=3s
Why do you use
to store a reference to an observer?
is nothing but
It is a convenience hook often used to store auto-updated refs to an elements (with its return value passed as a ref prop), or in rare cases when we need to update persistent state without causing component to re-render (by manually updating .current value)
Here you are just storing the reference, so it is more intuitive and less confusing to use
instead.
Also since you are still using ref but update it manually using "callback ref", the presence of useRef() in the code makes it harder to understand especially to a novice.
This is great. Do you have any solution for combining infinite scroll and scroll into view? I'm trying to implement into my project, which has a navigation that I can click to go to a certain section and update the active section on my navigation, and also update my navigation whenever I scroll to a section
for this hint you can make me louda
the page Number is incrementing even when the already intersected element comes down. how can we resolve this issue?
use this library to save time :)
react-query.tanstack.com/reference...