I want to trigger the reload function on scroll position. I set below code to trigger reload when contentOffset.y is smaller than -180 but it's being triggered multiple times as contentOffset.y's position keeps changing.
How do I make sure that reload is only triggered once?
_onScroll = (event) => {
if (event.nativeEvent.contentOffset.y < -180) {
this.webView.ref && this.webView.ref.reload();
console.log("Triggered multiple times as event.nativeEvent.contentOffset.y is keep changing")
}
};
Here is the WebView where it gets the scroll position.
<WebView
bounces={true}
onScroll={this._onScroll}
/>