Skip to content

Commit

Permalink
perf: perf context
Browse files Browse the repository at this point in the history
  • Loading branch information
linxianxi committed Jan 22, 2024
1 parent 8bded0c commit 2d0e818
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/VirtualTable/BodyLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
TableContext,
['prefixCls', 'flattenColumns', 'fixColumn', 'componentWidth', 'scrollX'],
);
const { getComponent } = useContext(StaticContext);
const { getComponent } = useContext(StaticContext, ['getComponent']);

const rowInfo = useRowInfo(record, rowKey, index, indent);

Expand Down
5 changes: 2 additions & 3 deletions src/VirtualTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CompareProps } from '@rc-component/context/lib/Immutable';
import classNames from 'classnames';
import { warning } from 'rc-util';
import { useEvent, warning } from 'rc-util';
import * as React from 'react';
import { INTERNAL_HOOKS } from '../constant';
import { makeImmutable } from '../context/TableContext';
Expand Down Expand Up @@ -55,9 +55,8 @@ function VirtualTable<RecordType>(props: VirtualTableProps<RecordType>, ref: Rea
}
}

const getComponent = React.useCallback<GetComponent>(
const getComponent = useEvent<GetComponent>(
(path, defaultComponent) => getValue(components, path) || defaultComponent,
[components],
);

// ========================= Context ==========================
Expand Down

0 comments on commit 2d0e818

Please sign in to comment.