【问题标题】:How to use Form.create in typescript and antd with function component如何在 typescript 和 antd 中使用 Form.create 和函数组件
【发布时间】:2019-04-24 08:04:09
【问题描述】:

我有一个由 Form.create() 创建的表单,但我无法编译成功。

类似的错误:

Argument of type 'FunctionComponent<MyProps>' is not assignable to parameter of type 'ComponentType<{}>'.
  Type 'FunctionComponent<MyProps>' is not assignable to type 'FunctionComponent<{}>'.
    Type '{}' is missing the following properties from type 'MyProps': form, and 2 more

我的代码是:

import { FormComponentProps } from "antd/lib/form";

interface MyProps extends FormComponentProps {
   form: any;
}

const TableQuery: FunctionComponent<MyProps> = (props: MyProps) => {
 // some code
};

const WrappedTableQuery = Form.create<MyProps>()(TableQuery)

export default WrappedTableQuery;

我该如何解决这个错误。

【问题讨论】:

标签: reactjs typescript antd


【解决方案1】:

我认为这是 Ant Design 中 TypeScript 定义的错误:
https://github.com/ant-design/ant-design/issues/16229(中文)
https://github.com/ant-design/ant-design/issues/16095#issuecomment-485709670(英文)

它出现在版本 3.16.4(发布于 2019-04-21)中,它仍然存在于版本 3.16.5。
在部署修复程序之前,您可以使用以前的版本 ("antd": "3.16.3")。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-16
    • 1970-01-01
    • 2021-04-24
    • 2020-07-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多