mirror of
https://github.com/plausible/analytics.git
synced 2024-12-20 16:11:49 +03:00
01538c9907
* WIP: add lazy loading for dashboard * Improve error handling * WIP * Implement lazy loading for most reports * Add lazy loading to conversions
31 lines
679 B
JavaScript
31 lines
679 B
JavaScript
import React from 'react';
|
|
|
|
export default class extends React.Component {
|
|
constructor(props) {
|
|
super(props)
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.observer = new IntersectionObserver((entries) => {
|
|
if (entries[0].isIntersecting) {
|
|
this.props.onVisible && this.props.onVisible()
|
|
this.observer.unobserve(this.element);
|
|
}
|
|
}, {
|
|
threshold: 0
|
|
});
|
|
|
|
this.observer.observe(this.element);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this.observer.unobserve(this.element);
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div ref={(el) => this.element = el} className={this.props.className} style={this.props.style}>{this.props.children}</div>
|
|
);
|
|
}
|
|
}
|