0

I'm building a custom component that has a normal <button> tag and I'm adding a new prop to it called aria-current.

The problem is that Typescript complains that this property does not exist inside <button>(and it doesnt). My question is: How to add this property to a simple <button> tag?

enter image description here

2
  • 1
    you could wrap it into a customized <Button/> you create. and then you add whatever props you wish !! Commented Nov 30, 2021 at 12:42
  • 1
    well still he will encounter the same problem because the base button cant get it. @oubaydos Commented Nov 30, 2021 at 12:45

2 Answers 2

2

enter image description here This property does exist on button, but you provide incorrect type. You need to specify the correct type and it will work fine

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

Comments

0

Hi before I could help can you add the reason why you want to add a props to button if the button tag dont get it's mean that he will never understand it and can't use it

UPDATE:

note that you can update but it will break the rest of the code you can look on this thread

How do I get the TypeScript engine to allow custom HTML attributes in JSX?

or this

How do I add attributes to existing HTML elements in TypeScript/JSX?

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.