[英]Ant design form issue
I am trying to build a table that is editable using ant design.我正在尝试使用 ant design 构建一个可编辑的表格。 going through exactly by documentation of ant design, there occurs an error.
完全通过蚂蚁设计的文档,出现错误。
Form.useForm()
is not a function Form.useForm()
不是函数
This is my code:这是我的代码:
import React, { Component } from "react"
import { Table, Input, Button, Form } from "antd"
const EditableContext = React.createContext()
const EditableRow = ({ index, ...props }) => {
const [form] = Form.useForm()
return (
<Form form={form} component={false}>
<EditableContext.Provider value={form}>
<tr {...props} />
</EditableContext.Provider>
</Form>
)
}
...
what I guess the problem is arising here: const [form] = Form.useForm()
我猜问题出在这里:
const [form] = Form.useForm()
What might be the solution?可能的解决方案是什么?
NB my ant design version is '^3.26.12'注意我的蚂蚁设计版本是'^3.26.12'
You are using AntD v3 and using the docs for v4.您正在使用 AntD v3 并使用 v4 的文档。 You should use the docs for v3 for this: https://3x.ant.design/docs/react/introduce
您应该为此使用 v3 的文档: https : //3x.ant.design/docs/react/introduce
This is where you find info about the form: https://3x.ant.design/components/form/您可以在此处找到有关表单的信息: https : //3x.ant.design/components/form/
https://ant.design/components/form/v3 - for migrating from v3 to v4 (if you want to use Form.useForm) https://ant.design/components/form/v3 - 用于从 v3 迁移到 v4(如果您想使用 Form.useForm)
Try updating you AntD version to v4.x or use documentation for AntD v3.x .尝试将您的 AntD 版本更新到 v4.x 或使用AntD v3.x 的文档。 AntD v4.x uses
const [form] = Form.useForm()
whereas AntD v3.x uses Form.create({ name: 'form-name' })
to create form. AntD v4.x 使用
const [form] = Form.useForm()
而 AntD v3.x 使用Form.create({ name: 'form-name' })
创建表单。 This is where you have to change.这是你必须改变的地方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.