Extending HTML elements in React and TypeScript while preserving props

后端 未结 6 1117
星月不相逢
星月不相逢 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

    I solve this code for me, you just have to import ButtonHTMLAttributes from react and that's it

    import { ButtonHTMLAttributes } from "react";
    
    interface MyButtonProps extends ButtonHTMLAttributes {
        children: any;
    }
    
    export const MyButton = (props: ButtonI) => {
        const { children } = props;
     
        return ;
    };
    

提交回复
热议问题