admin管理员组文章数量:1415467
I started using React with Typescript and I'm trying to add a "name" property to a "div" but Typescript is plaining about that and won't allow me to add it because that property doesn't exist.
This is the full message I get back:
Type '{ children: Element[]; name: string; className: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Property 'name' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.ts(2322)
How can I solve it? Here is an example of the .tsx file:
import React from "react";
export default function TestComponent() {
return <div name="ponent-name">Test</div>;
}
I'm using the library react-scroll that requires a name property on the ponent.
I started using React with Typescript and I'm trying to add a "name" property to a "div" but Typescript is plaining about that and won't allow me to add it because that property doesn't exist.
This is the full message I get back:
Type '{ children: Element[]; name: string; className: string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.
Property 'name' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.ts(2322)
How can I solve it? Here is an example of the .tsx file:
import React from "react";
export default function TestComponent() {
return <div name="ponent-name">Test</div>;
}
I'm using the library react-scroll that requires a name property on the ponent.
Share Improve this question edited May 17, 2022 at 12:49 Dave asked May 17, 2022 at 12:36 DaveDave 2,2104 gold badges20 silver badges40 bronze badges 3-
1
Delete
name="ponent-name"
from the source code.本文标签:
版权声明:本文标题:javascript - React with Typescript: Property 'name' does not exist on type 'DetailedHTMLProps<HTM 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745156954a2645232.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论