Skip to content

Commit

Permalink
feat: noStyle no warning (#48508)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Apr 17, 2024
1 parent a512f81 commit 0d34e0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/form/FormItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ function InternalFormItem<Values = any>(props: FormItemProps<Values>): React.Rea
childNode = mergedChildren(context as any);
} else {
warning(
!mergedName.length,
!mergedName.length || !!noStyle,
'usage',
'`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.',
);
Expand Down
9 changes: 9 additions & 0 deletions components/form/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,15 @@ describe('Form', () => {
);
});

it('No warning when use noStyle and children is empty', () => {
render(
<Form>
<Form.Item name="noWarning" noStyle />
</Form>,
);
expect(errorSpy).not.toHaveBeenCalled();
});

it('dynamic change required', async () => {
const { container } = render(
<Form>
Expand Down

0 comments on commit 0d34e0b

Please sign in to comment.