1

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 :(

3
  • That's right, an a element doesn't have a value attribute Commented Oct 15, 2017 at 16:01
  • I think you've mixed a with input, a has neither value nor type, whereas input has them both. Commented Oct 15, 2017 at 16:07
  • Ahha! Thank you for all!! Commented Oct 17, 2017 at 9:07

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.