Extending HTML elements in React and TypeScript while preserving props

后端 未结 6 1118
星月不相逢
星月不相逢 2021-02-04 23:58

I just can\'t wrap my head around this I guess, I\'ve tried probably half a dozen times and always resort to any... Is there a legitimate way to start with an HTML

6条回答
  •  时光取名叫无心
    2021-02-05 00:06

    Seems Like the above answer is outdated.

    In my case I'm wrapping a styled component with a functional component, but still want to expose regular HTML button properties.

    export const Button: React.FC> = ({ children, icon, ...props}) => ( 
      
         { icon && ({icon}< /i>)} 
         {children} 
       );

提交回复
热议问题