node.js - 将图标添加到项目材料表错误
问题描述
我正在尝试执行此操作https://github.com/mbrn/material-table但出现错误。我认为有问题是因为我使用的是 TSX 而不是 JSX?你知道怎么修吗?
No overload matches this call.
Overload 1 of 2, '(props: { component: ElementType<any>; } & { children?: ReactNode; color?: "primary" | "secondary" | "disabled" | "error" | "inherit" | "action" | undefined; fontSize?: "inherit" | ... 3 more ... | undefined; htmlColor?: string | undefined; shapeRendering?: string | undefined; titleAccess?: string | undefined; viewBox?: string | undefined; } & CommonProps<...> & Pick<...>): Element', gave the following error.
Property 'component' is missing in type '{ ref: ((instance: unknown) => void) | MutableRefObject<unknown> | null; children?: ReactNode; }' but required in type '{ component: ElementType<any>; }'.
Overload 2 of 2, '(props: DefaultComponentProps<SvgIconTypeMap<{}, "svg">>): Element', gave the following error.
Type '((instance: unknown) => void) | MutableRefObject<unknown> | null' is not assignable to type '((instance: SVGSVGElement | null) => void) | RefObject<SVGSVGElement> | null | undefined'.
Type 'MutableRefObject<unknown>' is not assignable to type '((instance: SVGSVGElement | null) => void) | RefObject<SVGSVGElement> | null | undefined'.
Type 'MutableRefObject<unknown>' is not assignable to type 'RefObject<SVGSVGElement>'.ts(2769)
OverridableComponent.d.ts(17, 7): 'component' is declared here.
和这里
No overload matches this call.
Overload 1 of 2, '(props: Readonly<MaterialTableProps<{ name: string; surname: string; birthYear: number; birthCity: number; }>>): MaterialTable<{ name: string; surname: string; birthYear: number; birthCity: number; }>', gave the following error.
Type '{ Add: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>; Check: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>; Clear: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>; ... 13 more ...; ViewColumn: React.ForwardRefExoticComponent<...>; }' is not assignable to type 'Icons'.
The types of 'Add.defaultProps' are incompatible between these types.
Type 'Partial<RefAttributes<unknown>> | undefined' is not assignable to type 'Partial<RefAttributes<SVGSVGElement>> | undefined'.
Type 'Partial<RefAttributes<unknown>>' is not assignable to type 'Partial<RefAttributes<SVGSVGElement>>'.
Types of property 'ref' are incompatible.
Type '((instance: unknown) => void) | RefObject<unknown> | null | undefined' is not assignable to type '((instance: SVGSVGElement | null) => void) | RefObject<SVGSVGElement> | null | undefined'.
解决方案
尝试这个
forwardRef<SVGSVGElement>
在图标中或
像这样导入图标:
import MaterialTable, { Icons } from 'material-table'
const tableIcons: Icons = {...}
推荐阅读
- java - 在 python 中使用 Java 自定义 StanfordCoreNLP 命名实体识别模型
- python - 从 Chrome 复制 Xpath 但仍然无法找到元素
- rest - 有没有办法在不牺牲我选择的编辑器的情况下利用 google colab 硬件资源?
- python - 给定日期列表作为 Python 中的 DateTime 对象,如何计算每个月的第一个星期五?
- wso2 - WSO2中json有效负载的base64编码
- javascript - 如何在多行 innerHTML 属性的 javascript 中包含 if 语句?
- python - Python多处理-在父类和衍生类之间共享的多处理数组中处理数据的问题
- python-3.x - 使用 Pymoo 重新启动优化
- apache-kafka - 使用来自 Kafka 主题的消息并将它们存储在目录 /tmp/kakfa-messages 中
- python - 由另一列 pandas df 分组的值出现的总和