Skip to content

Commit

Permalink
[PR feedback] Make empty array/obj stable references
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Mar 22, 2024
1 parent 1c4b1df commit 6bd5dde
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React, { useMemo, useCallback } from 'react';
import type { EuiDataGridSorting } from '@elastic/eui';
import type { EuiDataGridSorting, EuiDataGridSchemaDetector } from '@elastic/eui';
import { EuiButtonIcon, EuiCheckbox, EuiToolTip, useDataGridColumnSorting } from '@elastic/eui';
import { useDispatch } from 'react-redux';

Expand Down Expand Up @@ -64,6 +64,10 @@ const ActionsContainer = styled.div`
display: flex;
`;

// Defined statically to reduce rerenders
const emptySchema = {};
const emptySchemaDetectors: EuiDataGridSchemaDetector[] = [];

const HeaderActionsComponent: React.FC<HeaderActionProps> = ({
width,
browserFields,
Expand Down Expand Up @@ -196,8 +200,8 @@ const HeaderActionsComponent: React.FC<HeaderActionProps> = ({
const ColumnSorting = useDataGridColumnSorting({
columns: myColumns,
sorting: sortedColumns,
schema: {},
schemaDetectors: [],
schema: emptySchema,
schemaDetectors: emptySchemaDetectors,
displayValues,
});

Expand Down

0 comments on commit 6bd5dde

Please sign in to comment.