ant-design/components/form/hooks/useChildren.ts
二货爱吃白萝卜 e2606d477d
fix: form item support comment (#41771)
* fix: form item support comment

* chore: clean up

* fix: lint
2023-04-12 16:15:04 +08:00

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;
}