如果我在项目中使用typescript,那会否使React中prop-type的使用过时?对于prop-types,我将不得不经历定义类型的麻烦,但是对于typescript,这一步将被否定。我的想法正确吗?
听起来不错。使用TypeScript时,您可以通过界面定义道具。
interface ButtonProps {
text: string,
shadow?: boolean
}
const Button: React.FunctionComponent<ButtonProps> = props => {
return ( /* [...] */ );
};
看这里
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句