missgentle / New-Q-A

0 stars 0 forks source link

antd警告:'Instance created by `useForm` is not connect to any Form element. #1

Open missgentle opened 2 years ago

missgentle commented 2 years ago

Modal或Drawer等组件中使用Form表单,并且通过Form.useForm(), 获取form对象将其挂载到指定的Form表单后仍会出现

missgentle commented 2 years ago

原因: antd的Modal或Drawer等组件会在Form表单之前创建,因此当页面初始化时form对象会找不到可关联的Form表单

解决办法: Modal或Drawer组件添加 getContainer={false} 即可