ChaosWraith
ChaosWraith

Reputation: 65

How do you use "name" attribute in React?

My Environment

TypeScript ReactJS

The error I am receiving when attempting to use name as an attribute.

Type '{ name: string; "data-id": string; "data-type": string; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes, HTMLDivElement>'. Property 'name' does not exist on type 'DetailedHTMLProps<HTMLAttributes, HTMLDivElement>'

My current code that is throwing the error:

<div name="termly-embed" data-id="**************************" data-type="iframe"></div>

Upvotes: 4

Views: 4022

Answers (1)

Evren
Evren

Reputation: 4410

Since name property does not exist, it is custom so you can use data- attributes. Try to change it with data-name

<div data-name="termly-embed" data-id="**************************" data-type="iframe"></div>

Upvotes: 1

Related Questions