Skip to content

Commit 91601cd

Browse files
committed
fix: slight nanofixes
1 parent b86a4f0 commit 91601cd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/components/PaginatedTable/TableChunksRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export const TableChunksRenderer = <T, F>({
150150
);
151151

152152
const renderChunks = React.useCallback(() => {
153-
// Chunk states are distrubuted like [fetch, fetch, render/fetch, render/fetch, fetch, fetch]
153+
// Chunk states are distrubuted like [null, null, fetch, fetch, render+fetch, render+fetch, fetch, fetch, null, null]
154154
// i.e. fetched chunks include rendered chunks
155155
const {firstFetchIndex, lastFetchIndex} = findFetchChunkRange();
156156
const {firstRenderIndex, lastRenderIndex} = findRenderChunkRange();

src/components/PaginatedTable/useScrollBasedChunks.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from 'react';
22

3+
import {throttle} from 'lodash';
4+
35
import {rafThrottle} from './utils';
46

57
interface UseScrollBasedChunksProps {
@@ -23,6 +25,7 @@ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
2325
// Bad performance in Safari - reduce overscan counts
2426
const DEFAULT_RENDER_OVERSCAN = isSafari ? 1 : 2;
2527
const DEFAULT_FETCH_OVERSCAN = 4;
28+
const THROTTLE_DELAY = 200;
2629

2730
export const useScrollBasedChunks = ({
2831
scrollContainerRef,
@@ -95,7 +98,10 @@ export const useScrollBasedChunks = ({
9598
return undefined;
9699
}
97100

98-
const throttledHandleScroll = rafThrottle(handleScroll);
101+
const throttledHandleScroll = throttle(handleScroll, THROTTLE_DELAY, {
102+
trailing: true,
103+
leading: true,
104+
});
99105

100106
container.addEventListener('scroll', throttledHandleScroll, {passive: true});
101107
return () => {

0 commit comments

Comments
 (0)