ant-design/components/form/hooks/useChildren.ts
叶枫 502dac12aa
docs: format code (#48309)
* docs: fix code

* feat: lint

* feat: prettier

* feat: test

* feat: review

* feat: format html

* feat: format html
2024-04-08 14:04:08 +08:00

15 lines
378 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;
}