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.发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745156955a4614181.html
评论列表(0条)