mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 17:09:46 +08:00
14 lines
377 B
TypeScript
14 lines
377 B
TypeScript
|
import toArray from 'rc-util/lib/Children/toArray';
|
||
|
import type { FormItemProps } from '../FormItem';
|
||
|
|
||
|
export default function useChildren(
|
||
|
children?: FormItemProps['children'],
|
||
|
): FormItemProps['children'] {
|
||
|
if (typeof children === 'function') {
|
||
|
return children;
|
||
|
}
|
||
|
|
||
|
const childList = toArray(children);
|
||
|
return childList.length <= 1 ? childList[0] : childList;
|
||
|
}
|