question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Safari desktop triggers endless loop

See original GitHub issue

Hi!

I’m using inView to 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 inView being toggled between true and false when my scroll position is at the edge of the intersection point.

navbar

Any help with this?

const [primaryContainerRef, inView] = useInView();

<div className="primary-container" ref={primaryContainerRef}>
       This is the primary container
</div>

<SecondaryContainer isVisible={!inView} />

const SecondaryContainer = ({ isVisible }) => {
   return (
      {isVisible && (
          <div className="secondary-container">This is the secondary container</div>
     )}
   )
};

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
valerie-roskecommented, Jun 18, 2020

@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:

  • Make sure the observer element is loaded in an appropriate place in the DOM
  • If you are conditionally rendering the observer anyway, perhaps position: fixed is a better choice than position: sticky
  • If you aren’t conditionally rendering, then you may not even need an IntersectionObserver in the first place and can go ahead with position: sticky all by itself

Not sure if this is exactly what’s going on in the original post, but I hope this helps. 😃

1reaction
macrozonecommented, Apr 24, 2020

can confirm that 8.26.2 fixes the issue in chrome 80 (and 81)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Web page in Safari is and endless loop - … - Apple Community
Web page in Safari is and endless loop - how can I stop it · 1. Kill Safari if it's running. · 2....
Read more >
google ads enableLazyLoad causes endless loop on safari ...
This works fine on chrome, firefox and edge. However on safari and IE it causes an endless loop which freezes the page. I'm...
Read more >
Teams App and Browser stuck in an endless loop
It yet again opened with an unresponsive white screen and triggered the endless loop of opening a new tab with meeting options and...
Read more >
Firefox and Safari: endless loop with 'toUnifiedPlan'?
This seems to be caused by the “toUnifiedPlan” method. Using the profiling tools of the browser it seems to be triggered by “renegotiationneed”....
Read more >
Trying to create endless loop macro (Repeat or For Each ...
How does CMD-Click trigger your macro? gglick January 21, 2020, 12:25am #22. ronald: When I changed by default browser to safari, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found