react+ant-design-pro 解决报错:Warning: Instance created by `useForm` is not connected to any Form elemen

解决报错:Warning: Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?

这是由于,在首次加载 Modal 拿不到延迟的 form 信息造成的。

在 Modal 弹框里加入 forceRender 即可。

举个例子:

<Modal 
    forceRender
    visible={visible} 
    onOk={onClose} 
    onCancel={onClose}
>
    <Form form={form}>
        <Form.Item name="user">
            <Input />
        </Form.Item>
    </Form>
</Modal>

猜你喜欢

转载自blog.csdn.net/mChales_Liu/article/details/112613207
今日推荐