Skip to content

Commit

Permalink
fix: reduce the ready state reporting frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
petyosi committed Aug 14, 2024
1 parent 9f124f1 commit 693b77f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export function ReadyStateChanged() {
<>
<VirtuosoGrid
ref={ref}
readyStateChanged={setGridVisible}
readyStateChanged={(value) => {
setGridVisible(value)
}}
components={{
Item: ItemContainer,
List: ListContainer,
Expand Down
6 changes: 5 additions & 1 deletion src/VirtuosoGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 693b77f

Please sign in to comment.