ParkMinchul
ParkMinchul

Reputation: 105

Typescript React type Attribute

While I make write code with Typescript + React, I found some error.

When I make type/value in <a> tag attribute, I get compile Error.

<a value='Hello' type='button'>Search</a>

This code get occur error

TS2339:Property 'value' does not exist on type 'DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>'.

How can I solve this compile problem? I search few hours but I cannot get solution :(

Upvotes: 1

Views: 1632

Answers (1)

Tomas Ramirez Sarduy
Tomas Ramirez Sarduy

Reputation: 17471

Because value is not a valid HTML attribute for the <a> element. I think the best would be to use an attribute like <a data-value="Hello"> instead of trying to extend the AnchorHTMLAttributes interface.

Upvotes: 3

Related Questions