我正在构建一个按钮组件:
interface ButtonProps {
startIcon?: ... <-- what type?
}
const Button = ({startIcon: StartIcon}) => {
return <button>{StartIcon && <StartIcon/>}</button>
}
// usage
<Button startIcon={SomeIcon}/>
我正在使用react-icons
库,我应该在接口中声明什么类型?如果我将 svg 元素作为 startIcon 道具传递,它对类型声明有影响吗?