From ccbec335856f7beb6c25083696fd82f551356cd9 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Mon, 2 Jan 2023 22:18:35 +0800 Subject: [PATCH] type: remove redundant useContext (#39955) * type: remove redundant useContext * add type --- components/cascader/index.tsx | 2 +- components/table/Table.tsx | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index a3efedfdea..58334f568b 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -148,7 +148,7 @@ const Cascader = React.forwardRef((props: CascaderProps, ref: React.Ref( ); }, [baseColumns, screens]); - const tableProps = omit(props, ['className', 'style', 'columns']) as TableProps; + const tableProps: TableProps = omit(props, ['className', 'style', 'columns']); + + const size = React.useContext(SizeContext); - const size = React.useContext(SizeContext); const { locale: contextLocale = defaultLocale, - renderEmpty, direction, - } = React.useContext(ConfigContext); + renderEmpty, + getPrefixCls, + } = React.useContext(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);