type: remove redundant useContext (#39955)

* type: remove redundant useContext

* add type
This commit is contained in:
lijianan 2023-01-02 22:18:35 +08:00 committed by GitHub
parent b44b4e7705
commit ccbec33585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -148,7 +148,7 @@ const Cascader = React.forwardRef((props: CascaderProps<any>, ref: React.Ref<Cas
...rest
} = props;
const restProps = omit(rest, ['suffixIcon' as any]);
const restProps = omit(rest, ['suffixIcon']);
const {
getPopupContainer: getContextPopupContainer,

View File

@ -5,6 +5,7 @@ import type { TableProps as RcTableProps } from 'rc-table/lib/Table';
import { INTERNAL_HOOKS } from 'rc-table/lib/Table';
import omit from 'rc-util/lib/omit';
import * as React from 'react';
import type { ConfigConsumerProps } from '../config-provider/context';
import { ConfigContext } from '../config-provider/context';
import defaultRenderEmpty from '../config-provider/defaultRenderEmpty';
import type { SizeType } from '../config-provider/SizeContext';
@ -169,19 +170,21 @@ function InternalTable<RecordType extends object = any>(
);
}, [baseColumns, screens]);
const tableProps = omit(props, ['className', 'style', 'columns']) as TableProps<RecordType>;
const tableProps: TableProps<RecordType> = omit(props, ['className', 'style', 'columns']);
const size = React.useContext<SizeType>(SizeContext);
const size = React.useContext(SizeContext);
const {
locale: contextLocale = defaultLocale,
renderEmpty,
direction,
} = React.useContext(ConfigContext);
renderEmpty,
getPrefixCls,
} = React.useContext<ConfigConsumerProps>(ConfigContext);
const mergedSize = customizeSize || size;
const tableLocale = { ...contextLocale.Table, ...locale } as TableLocale;
const tableLocale: TableLocale = { ...contextLocale.Table, ...locale };
const rawData: readonly RecordType[] = dataSource || EMPTY_LIST;
const { getPrefixCls } = React.useContext(ConfigContext);
const prefixCls = getPrefixCls('table', customizePrefixCls);
const dropdownPrefixCls = getPrefixCls('dropdown', customizeDropdownPrefixCls);