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.

Trigger re-calculation of visibility from outside the component

See original GitHub issue

Hi, I’ve got a scenario where unmounting components brings others into view. As neither a scroll nor resize event is fired so no computation is done. My current thinking is to have a prop be passed in (say detectOnChange) and when that prop changes we trigger a re-calculation of visibility.

In my use case, I’ve got a series of accordions. Inside those accordion are visibility tracked components. Closing one of those accordions brings other components into view. What I’m doing is tracking the state of open accordions and passing the count of open accordions to the tracked component. Then on change I can fire the isComponentVisible function.

What are your thoughts?

Thanks, Tom

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
tapayne88commented, Feb 9, 2018

Yeah, it looks interesting. I don’t see a problem with both solutions co-existing. I’ll put together a PR with what I was suggesting, don’t hold back as it’s a little out there!

0reactions
fkhadracommented, Feb 9, 2018

Hey,

I think that it can be a good idea to extend PureComponent. At least we can try and see if there is any performance impact.

I also like the idea to add a third event like https://github.com/Stanko/window-scroll-manager.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conditional visibility in a react component - Stack Overflow
I have a react component that contains a div with a conditional visibility. The component represents the page of a specific product on...
Read more >
The Element Visibility Trigger In Google Tag Manager
In short, the Element Visibility trigger fires whenever an element, or elements, you specify appear in the browser's viewport.
Read more >
Flow Conditional Visibility Considerations - Salesforce Help
Before you set visibility for a screen component, understand the behavior of conditional visibility in flows.Required Editions Available in: both Salesfor.
Read more >
Controlling component visibility with React Hooks
Here we have set up a hook to control the visibility of the component. The initial state value is null as this will...
Read more >
Report visibility tracking ineligible in amp-analytics visible trigger ...
In case such a cooperation is failed to be established, we might want amp-analytics to report back to ad server or 3rd party...
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