ant-design/components/_util/index.en-US.md
lijianan 0a79a79bc7
docs: update sidebar style of website (#48224)
* docs: update GetRef/GetProp/GetProps docs

* fix: fix

* fix: fix

* fix: fix

* fix: fix

* fix: fix
2024-04-02 14:05:03 +08:00

1.3 KiB

category title description showImport cover coverDark tag demo group
Components Util Utilities are used to assist development and provide some common utility methods. false https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*rRDlT7ST8DUAAAAAAAAAAAAADrJ8AQ/original https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*rRDlT7ST8DUAAAAAAAAAAAAADrJ8AQ/original 5.13.0
cols
2
title order
Other 99

Available since 5.13.0.

GetRef

Get the ref property definition of the component, which is very useful for components that are not directly exposed or child components.

import { Select } from 'antd';
import type { GetRef } from 'antd';

type SelectRefType = GetRef<typeof Select>; // BaseSelectRef

GetProps

Get the props property definition of the component:

import { Checkbox } from 'antd';
import type { GetProps } from 'antd';

type CheckboxGroupType = GetProps<typeof Checkbox.Group>;

GetProp

Get the single props property definition of the component. It has encapsulated NonNullable, so you don't have to worry about being empty:

import { Select } from 'antd';
import type { GetProp, SelectProps } from 'antd';

// Both of this can work
type SelectOptionType1 = GetProp<SelectProps, 'options'>[number];
type SelectOptionType2 = GetProp<typeof Select, 'options'>[number];