码迷,mamicode.com
首页 > 其他好文 > 详细

[Ant Design] Warning: Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?

时间:2020-05-01 01:13:12      阅读:734      评论:0      收藏:0      [点我收藏+]

标签:描述   问题   info   warning   使用   png   创建   警告   form   

问题描述

antd: 4.2.0, react: 16.13.1

Modal 中使用 Form ,使用 React Hooks const [form] = Form.useForm(); 创建实例时,会出现以下警告。

技术图片

原因

Modal 挂载的 HTML 节点默认为 document.body,页面初始化时,在当前模块下找不到 Form 表单。

解决方案

Modal 添加属性 getContainer={false} ,挂载在当前 dom。


[Ant Design] Warning: Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?

标签:描述   问题   info   warning   使用   png   创建   警告   form   

原文地址:https://www.cnblogs.com/whosmeya/p/12811837.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!