[英]How do you extract prop types from a React Component with defaultProps?
Exporting Props from a React.Component is easy enough, but how do you properly extract the types the Component is actually using, once defaultProps
are taken into account? 从React.Component导出道具很容易,但是一旦考虑了
defaultProps
,如何正确地提取组件实际使用的类型? I imagine you could omit keys from Props and then merge with a Partial of defaultProps, but are there any built-in ways of this? 我想您可以从Props中省略键,然后与defaultProps的Partial合并,但是有任何内置方法吗? Flow accomplishes this with
React.ElementConfig
流程通过
React.ElementConfig
完成
您正在寻找:
JSX.LibraryManagedAttributes<typeof MyComponent, MyComponent["props"]>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.