expose `.propTypes` and `.defaultProps` on the wrapper
yzimet opened this issue · comments
When used in conjunction with react-validator
's .passedInto
method, we need the .proptypes
of the wrapped component to be exposed on the wrapper: https://github.com/airbnb/react-with-styles/blob/master/src/withStyles.jsx#L60-L62
Maybe hoistNonReactStatics
is supposed to do this, but it doesn't seem to be working.
hoistNonReactStatics
only hoists statics that are non-React.
I think hoisting propTypes might be okay, but I worry a little that the warning it will generate may end up being confusing for some developers. E.g. instead of telling you that the props you are passing to MyComponent
aren't correct, it will tell you that the props you are passing to withStyles(MyComponent)
aren't correct. Naturally, this will include every HOC the component is wrapped with after withStyles in the message. This is probably just fine though. And, on the flipside, the error message will be more accurate with which render method to look at, so that's a bigger win I guess.
Is this practice something we should add to the React style guide?
copying over the propTypes and defaultProps on HOCs? Yes, I think so.