fix: Form.Item with name 0 should be validate (#21179)

* fix FormItem missing name

* update test case
This commit is contained in:
二货机器人 2020-02-02 22:28:05 +08:00 committed by GitHub
parent 92998e67ef
commit 207fc03c91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -189,7 +189,7 @@ function FormItem(props: FormItemProps): React.ReactElement {
const isRenderProps = typeof children === 'function';
if (!name && !isRenderProps && !dependencies) {
if (name === undefined && !isRenderProps && !dependencies) {
return renderLayout(children as ChildrenNodeType);
}

View File

@ -428,4 +428,14 @@ describe('Form', () => {
expect(wrapper.find('.ant-form-item-required')).toHaveLength(1);
});
it('0 is a validate Field', () => {
const wrapper = mount(
<Form.Item name={0}>
<input />
</Form.Item>,
);
expect(wrapper.find('Field')).toHaveLength(1);
});
});