简体   繁体   中英

Extending HTML <a> tag elements in React and TypeScript

I am using typescript in a React project and I want to add tag's props. I can access the properties of the link element but not the properties a element. I am getting an error when the properties of the link tag use an a tag.

Is there an 'HTMLAElement' structure for an element a in React?

const MyComponent: FunctionComponent<React.LinkHTMLAttributes<HTMLLinkElement>> = (
props: React.LinkHTMLAttributes<HTMLLinkElement>,
) => {
  return (
      <a {...props} className="mycomponent">  // When I use it with the <link> it doesn't give an error but I need <a>.
         MyComponent
      </a>
  );
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM