From a4a20ddbe61e0b67cfb7eed26aa85754f677bdf5 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 2 Jun 2022 20:36:49 -0500 Subject: [PATCH] ScrollableList: use debounce, not throttle --- app/soapbox/components/scrollable_list.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/soapbox/components/scrollable_list.tsx b/app/soapbox/components/scrollable_list.tsx index ae9b861e9..510f186af 100644 --- a/app/soapbox/components/scrollable_list.tsx +++ b/app/soapbox/components/scrollable_list.tsx @@ -1,4 +1,4 @@ -import { throttle } from 'lodash'; +import { debounce } from 'lodash'; import React, { useEffect, useRef, useMemo, useCallback } from 'react'; import { useHistory } from 'react-router-dom'; import { Virtuoso, Components, VirtuosoProps, VirtuosoHandle, ListRange, IndexLocationWithAlign } from 'react-virtuoso'; @@ -106,7 +106,7 @@ const ScrollableList = React.forwardRef(({ data.push(); } - const handleScroll = useCallback(throttle(() => { + const handleScroll = useCallback(debounce(() => { // HACK: Virtuoso has no better way to get this... const node = document.querySelector(`[data-virtuoso-scroller] [data-item-index="${topIndex.current}"]`); if (node) {