Skip to content

Commit e79e898

Browse files
committed
Remove unneeded render work
1 parent 49a422b commit e79e898

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

packages/core/src/data-editor/data-editor.tsx

+5-10
Original file line numberDiff line numberDiff line change
@@ -817,9 +817,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
817817
return window.getComputedStyle(document.documentElement);
818818
}, []);
819819

820-
const fontSizeStr = docStyle.fontSize;
821-
822-
const remSize = React.useMemo(() => Number.parseFloat(fontSizeStr), [fontSizeStr]);
820+
const remSize = React.useMemo(() => Number.parseFloat(docStyle.fontSize), [docStyle]);
823821

824822
const { rowHeight, headerHeight, groupHeaderHeight, theme, overscrollX, overscrollY } = useRemAdjuster({
825823
groupHeaderHeight: groupHeaderHeightIn,
@@ -856,13 +854,10 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
856854
}, [gridSelectionOuter, rowMarkerOffset]);
857855
const gridSelection = gridSelectionOuterMangled ?? gridSelectionInner;
858856

859-
const abortControllerRef = React.useRef(new AbortController());
860-
React.useEffect(() => {
861-
return () => {
862-
// eslint-disable-next-line react-hooks/exhaustive-deps
863-
abortControllerRef?.current.abort();
864-
};
865-
}, []);
857+
const abortControllerRef = React.useRef() as React.MutableRefObject<AbortController>;
858+
if (abortControllerRef.current === undefined) abortControllerRef.current = new AbortController();
859+
860+
React.useEffect(() => () => abortControllerRef?.current.abort(), []);
866861

867862
const [getCellsForSelection, getCellsForSeletionDirect] = useCellsForSelection(
868863
getCellsForSelectionIn,

packages/core/src/internal/data-grid-search/data-grid-search.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ const DataGridSearch: React.FunctionComponent<DataGridSearchProps> = p => {
141141
}
142142
}, [rows, searchResultsIn]);
143143

144-
const abortControllerRef = React.useRef(new AbortController());
144+
const abortControllerRef = React.useRef() as React.MutableRefObject<AbortController>;
145+
if (abortControllerRef.current === undefined) abortControllerRef.current = new AbortController();
146+
145147
const searchHandle = React.useRef<number>();
146148
const [searchResultsInner, setSearchResultsInner] = React.useState<readonly Item[]>([]);
147149
const searchResults = searchResultsIn ?? searchResultsInner;

0 commit comments

Comments
 (0)