Open ArbaazDossani opened 5 years ago
This can probably be done by separating your components and using lifecycle hooks (ComponentDidMount & ComponentWillUnmount), for example:
class MyComponent extends React.PureComponent {
componentDidMount() {
this._timeout = setTimeout(() => {
// make request after being mounted for 5 seconds
}, 5000);
}
componentWillUnmount() {
clearTimeout(this._timeout);
}
}
<VisibilitySensor>
{({isVisible}) => <MyComponent />
</VisibilitySensor>
I need a callback if the user has stopped scrolling and an element is in view for more than x seconds