From 693b77f57e74e53fac69f2a5bfda132c5858a28d Mon Sep 17 00:00:00 2001 From: Petyo Ivanov Date: Wed, 14 Aug 2024 09:32:46 +0300 Subject: [PATCH] fix: reduce the ready state reporting frequency --- examples/grid.tsx | 4 +++- src/VirtuosoGrid.tsx | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/grid.tsx b/examples/grid.tsx index 89273d12a..42b5655c5 100644 --- a/examples/grid.tsx +++ b/examples/grid.tsx @@ -86,7 +86,9 @@ export function ReadyStateChanged() { <> { + setGridVisible(value) + }} components={{ Item: ItemContainer, List: ListContainer, diff --git a/src/VirtuosoGrid.tsx b/src/VirtuosoGrid.tsx index eb89fc47f..88ee3472b 100644 --- a/src/VirtuosoGrid.tsx +++ b/src/VirtuosoGrid.tsx @@ -36,8 +36,12 @@ const gridComponentPropsSystem = /*#__PURE__*/ u.system(() => { const readyStateChanged = u.statefulStream(false) + const reportReadyState = u.statefulStream(false) + u.connect(u.duc(reportReadyState), readyStateChanged) + return { readyStateChanged, + reportReadyState, context, itemContent, components, @@ -75,7 +79,7 @@ const GridItems: React.FC = /*#__PURE__*/ React.memo(function GridItems() { const gridGap = usePublisher('gap') const log = useEmitterValue('log') const stateRestoreInProgress = useEmitterValue('stateRestoreInProgress') - const reportReadyState = usePublisher('readyStateChanged') + const reportReadyState = usePublisher('reportReadyState') const listRef = useSize( React.useMemo(