Antd form and modal are used together to report an error Warning: Instance created by `useForm` is not connect to any Form element

Why is there an error when calling the form console in Modal?

Warning: Instance created by useForm is not connect to any Form element. Forget to pass form prop?
insert image description here
This is because when you call the form method, the Modal has not been initialized and the form is not associated with any Form component. You can pre-render the Modal by setting forceRender to it.
form needs to set form={form}

insert image description here

Initialize form form data

const [form] = Form.useForm()
form.setFieldsValue(initialization data)

Guess you like

Origin blog.csdn.net/weixin_47541876/article/details/125291484