-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: add lazy loading for dashboard (#859)
* WIP: add lazy loading for dashboard * Improve error handling * WIP * Implement lazy loading for most reports * Add lazy loading to conversions
- Loading branch information
Showing
16 changed files
with
187 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.