|
|
|
|
|
by acemarke
3178 days ago
|
|
As a real quick example, purely off the top of my head: @connect(state => ({a : state.a})
class MyComponent extends React.Component {}
MyComponent.propTypes = {a : PropTypes.string.required, b : PropTypes.number.required}
MyComponent.defaultProps = {b : 42}
In this example, both the propTypes and defaultProps definitions are being applied to the wrapper component, not the actual "plain" MyComponent class. So, while the required `b` prop might get satisfied almost accidentally from the defaultProps value, the required `a` prop won't exist on the wrapper, as the wrapper itself is extracting that value from the Redux state internally and passing it to the plain MyComponent.I've definitely seen this pop up as a recurring question that's confused people. |
|