Skip to content

Commit

Permalink
fix: changed debounce to setTimout
Browse files Browse the repository at this point in the history
  • Loading branch information
yaredtsy committed Nov 8, 2022
1 parent 5a019dd commit 2535600
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/grid/x-data-grid/src/components/base/GridBody.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { debounce } from 'lodash';
import { useGridPrivateApiContext } from '../../hooks/utils/useGridPrivateApiContext';
import { ElementSize } from '../../models/elementSize';
import { GridMainContainer } from '../containers/GridMainContainer';
Expand Down Expand Up @@ -59,7 +58,6 @@ function GridBody(props: GridBodyProps) {
const columnHeadersRef = React.useRef<HTMLDivElement>(null);
const columnsContainerRef = React.useRef<HTMLDivElement>(null);
const renderingZoneRef = React.useRef<HTMLDivElement>(null);
const gridReadyEvent = debounce(() => apiRef.current.publishEvent('gridReady'), 100);

apiRef.current.columnHeadersContainerElementRef = columnsContainerRef;
apiRef.current.columnHeadersElementRef = columnHeadersRef;
Expand All @@ -72,13 +70,14 @@ function GridBody(props: GridBodyProps) {
const unsubscribe = apiRef.current.subscribeEvent('stateChange', (newState) => {
// TODO: Improve a way to check if all states have finished initialization.
if (newState.rowsMeta.currentPageTotalHeight > 0) {
gridReadyEvent();
setTimeout(() => apiRef.current.publishEvent('gridReady'), 100);

unsubscribe();
}
});
}
},
[apiRef, gridReadyEvent],
[apiRef],
);

const handleResize = React.useCallback(
Expand Down

0 comments on commit 2535600

Please sign in to comment.