React·100 questions

How to use IntersectionObserver in React?

Answer
Create a ref on the sentinel element.
In an effect, create an observer and subscribe.
In callback, trigger loading of the next page.
Don't forget cleanup: disconnect.
Consider dependencies and stale closures.
Was this answer helpful?

More questions in this topic

Related questions from other topics