ant-design/components/form/util.ts
二货机器人 a9a651ffd5
fix: Form List warning (#24867)
* fix: Form List warning

* clean reaf
2020-06-09 18:10:43 +08:00

15 lines
480 B
TypeScript

import { InternalNamePath } from './interface';
export function toArray<T>(candidate?: T | T[] | false): T[] {
if (candidate === undefined || candidate === false) return [];
return Array.isArray(candidate) ? candidate : [candidate];
}
export function getFieldId(namePath: InternalNamePath, formName?: string): string | undefined {
if (!namePath.length) return undefined;
const mergedId = namePath.join('_');
return formName ? `${formName}_${mergedId}` : mergedId;
}