javascript - React with Typescript: Property 'name' does not exist on type 'DetailedHTMLProps<HTM

I started using React with Typescript and I'm trying to add a "name" property to a "

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信