trouble shooting/next.js

A `Form.Item` with a `name` prop must have a single child element

일상코더 2023. 4. 28. 11:19

회사에서 백오피스를 개발하던중 발생 했던 에러 이다. 

 

Warning: [antd: Form.Item] A `Form.Item` with a `name` prop 

must have a single child element. For information on 

how to render more complex form items, see https://u.ant.design/complex-form-item

 

 

 

<Form.Item> 태그 안에 두종류의 태그가 들어가 있을때 발생하는 에러인 것 같다. 

나는 <Checkbox.Group> 태그만 사용하는중이 었으나 간격을 위해 <br/> 태그도 사용하고 있는것을 모르고 계속 헤맸다.

<br/> 태그를 지워주니 정상적으로 동작했다.

이러한 에러가 발생한다면 매우간단하게 기본적인 태그를 사용하고 있는지 부터 확인해 보는게 좋을것 같다.

 

 

antd docs에서 multiple 태그를 사용하는 방법이 잘 나와있으니 참고 하면 좋을 것 같다.

 

https://ant.design/components/form#components-form-demo-complex-form-control

 

Form - Ant Design

colorBorderDefault border color, used to separate different elements, such as: form separator, card separator, etc.string#d9d9d9colorErrorUsed to represent the visual elements of the operation failure, such as the error Button, error Result component, etc.

ant.design