onderonur / react-intersection-observer-hook Goto Github PK
View Code? Open in Web Editor NEWReact hook to use IntersectionObserver declaratively.
Home Page: https://onderonur.github.io/react-intersection-observer-hook/
License: MIT License
React hook to use IntersectionObserver declaratively.
Home Page: https://onderonur.github.io/react-intersection-observer-hook/
License: MIT License
Hi there! First of all thank you for this very useful lib; I used it a few times now and usually it works as expected. But I had a scenario where i wanted to update the rootMargin
upon window.resize. Unfortunately the current implementation does not update the observer instance when the config of the observer changes.
Before I suggest a possible solution to this problem I wanted to ask if you are at all interested to solve this problem—or if you maybe took this into consideration already when building the current implementation.
Hi there,
I have a react component that uses your react-infinite-scroll-hook and couldn't get tests for it to work properly. I would always get the following error:
ReferenceError: IntersectionObserver is not defined
Here is a minimal reproduction example. I also used intersetion-observer polyfill as a workaround for this issue and it seems to work fine. Just toggle the first import statement in App.js
.
By the way, when I tried testing that component with plain @testing-library/react
, it worked just fine.
Hi,
Since last update my tests that use mockAllIsIntersecting
from react-intersection-observer/test-utils
are failing. Is there a known issue that connects this failing to the latest update?
Hi, thanks for creating this!
So I want to track a list of items (chat messages in an infinite scrolling list) in a custom scrollable div. If I understand correctly, this means I should use rootRef
for the parent. However, since I have multiple children, I need a ref
for every chilld, but only one for the parent. Does this library support this? I tried setting the root
in the options (passing the parentRef
), but for some reason that does not work.
Hi,
I know it's a bit early to dive into React 18 since it's only in alpha but I have to use it because of relay routing and concurrent mode.
Moving to this alpha version happened to break useInfiniteScroll
. With (painful) debugging in console, the further I could go is in this package and I saw that the IntersectionObserver callback was never called.
I tried to use this package directly instead of useInfiniteScroll
, see if I would have better luck but it didn't work either.
I was wondering if React concurrent mode completely broke with IntersectionObserver (since ReactDOM
initialization is done in a different way now) but following this tutorial, I was able to put it back on track. I had to remove the ref
from the dependencies of useEffect
to make it work though, leading to delete / recreate my observer on every render. Twice actually, because of "double render effect", but at least it works.
I don't know exactly what's going on with intersectionObserverHook
but just so you know, it breaks.
Have a good one ;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.