make sure comments are rendered before trying to render more

This commit is contained in:
Sean Yesmunt 2020-10-06 16:33:51 -04:00
parent c1b5280446
commit 0326e266d4

View file

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