简体   繁体   中英

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? 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? Flow accomplishes this with React.ElementConfig

您正在寻找:

JSX.LibraryManagedAttributes<typeof MyComponent, MyComponent["props"]>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM