-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safari desktop triggers endless loop #308
Comments
|
I would try setting |
|
Thanks, I tried both of those, but no luck. |
|
Can you replicate it in a Code Sandbox? |
|
I'm seeing an infinite loop as well, I tracked it down to the upgrade from |
|
I'm experiencing performance degration on Chrome 80.0.3987.132 with react-intersection-observer 8.26.1 Same with render prop and useInView |
|
@gabrieltomescu I'm currenly using NextJS. I attached the ref to an anchor tag inside a Next/Link component: import Link from 'next/link';
...
<Link to="/">
<a ref={ref}>Some component</a>
</Link>Got rid of the issue when applying to a child component to Edit: CodeSandbox example here: https://codesandbox.io/s/nextjs-o0783 Move the ref to the child div to stop the infinite loop. |
The Codesandbox example goes into an infinite loop because of a missing |
|
I also see a massive performance degeneration with chrome 80.
|
* fix: don't clear the inView state if we get a node #308 * fix: use a useEffect to trigger the cleanup
|
can confirm that 8.26.2 fixes the issue in chrome 80 (and 81) |
|
Can you share the code that caused the issue? Would like to know if it's related to switch |
its nothing special, i did not change the ref target. If it helps: i assigend the ref usually to a component that was created with |
|
the error seem to have reappeared in chrome 81. :-( |
|
@thebuilder I'm on version 8.26.2 and I'm experiencing the same issue as @gabrieltomescu in Safari only. The code is set up the same way. This issue seems to occur for me only when the observing element is sticky to the top (using |
|
@valerie-roske Can you make a Codesandbox demo of the issue? |
|
@thebuilder here you go: https://codesandbox.io/s/react-intersection-observer-p9ide So another observation as I was making this demo: the order on the DOM is relevant. In my example, the flickering occurs only when the observer element is inserted above the element it's observing. So for anyone coming across this issue, potential solutions:
Not sure if this is exactly what's going on in the original post, but I hope this helps. :) |
|
Thanks for the sandbox @valerie-roske - It seems to be an issue in all browsers, but I think the library is actually acting correctly. When you attach the new element with position sticky it causes a layout shift. This in turn causes the IntersectionObserver to trigger again. In Firefox and Chrome it only seems to have once per scroll event, so it causes flickering while scrolling, with Safari going into an infinite loop. |
Hi!
I'm using
inViewto detect if a container is in view, then setting this property to a secondary container that should be visible when the first one is out of view.In Chrome this works fine, but in Safari I'm getting a endless loop of
inViewbeing toggled betweentrueandfalsewhen my scroll position is at the edge of the intersection point.Any help with this?
The text was updated successfully, but these errors were encountered: