don't add scroll listener until comments have been fetched

This commit is contained in:
Sean Yesmunt 2020-10-06 16:13:42 -04:00
parent 00c05437ca
commit fc2a79242e

View file

@ -111,14 +111,14 @@ function CommentList(props: Props) {
}
}
if (moreBelow && spinnerRef && spinnerRef.current) {
if (!isFetchingComments && moreBelow && spinnerRef && spinnerRef.current) {
window.addEventListener('scroll', handleCommentScroll);
}
return () => window.removeEventListener('scroll', handleCommentScroll);
}, [moreBelow, handleMoreBelow, spinnerRef]);
function prepareComments(arrayOfComments, linkedComment) {
function prepareComments(arrayOfComments, linkedComment, isFetchingComments) {
let orderedComments = [];
if (linkedComment) {