Introduction
What is infinite scroll ?
Infinite scrolling is a web-design technique that loads content continuously as the us...
For further actions, you may consider blocking this person and/or reporting abuse
Here is a cleaner version of the code above that compliance with Eslint.
There is a problem with the code . It'll add infinite number of elements without being triggered by scrolling to the end of the list.
Be carefull... that
postList.list
as dependencies will make your component enter an infinite loop of rerenders. It is better to access this property via an arrow function.Also,
handleObserver
is better to be insde the useEffect function and you should clear (observer.unobserve) the listener on a callback funtion. ;)Nice, Kakarot. I will for sure try it out ✨
Thank you for reading, and yes please go try it out :)
You wrote
ContactPage
function and exportInfiniteScroll
! Should review the code and fixhaha yes, I think he has tried to copy-paste and forget to change the name of function 😁
Updated thank you, Yup you are right left over while copying from VS code :D
How would I turn off this observer when certain conditions are met, for example if some state changes (ie, I make it to the last set of items/last page)? I've tried observer.disconnect inside the useEffect hook, but it does not seem to work.
Thanks good article I will try this out.
Reading y is unnecessary in handleObserver.
Yes you are right
Thank you!
Nice article! But please add the javascript tag to the code-blocks for syntax highlights
why dont you have syntax highlighting?
Thank you very much, brother
Failed to compile due to 'IntersectionObserver' is not defined no-undef.
Has anyone faced such issue?
Hmm you should not have that issue, you can check how intersectionObserver is used here:developer.mozilla.org/en-US/docs/W...
It is now working with windows.IntersectionObserver
My handleObserver is being called twice with this code D:
Easy steps to follow to create a user friendly Website