[英]Auto-Complete in vs-code for custom button component in react using Flow.js
I am creating a Custom Button component in React.我正在 React 中创建一个自定义按钮组件。 The basic version of the component looks something like this -
该组件的基本版本如下所示 -
// @flow
type ButtonPropsType = {};
const Button = (props: ButtonPropsType) => {
const { children, ...rest } = props;
return <button {...rest}>{children}</button>
}
let App = () => {
return (
<div>
<Button style={{ margin: 10 }}>Sahil Kapoor</Button>
</div>
)
}
How should I define the type of my Button component so that VS-Code knows that my Button component accepts all the attributes of a normal React button element like style, onClick, className etc?我应该如何定义我的 Button 组件的类型,以便 VS-Code 知道我的 Button 组件接受普通 React 按钮元素的所有属性,如样式、onClick、className 等?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.