Ross Solomon
Ross Solomon

Reputation: 665

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

Upvotes: 1

Views: 636

Answers (1)

Matt McCutchen
Matt McCutchen

Reputation: 30999

You are looking for:

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

Upvotes: 2

Related Questions