I'm probably doing something stupid, but I can't get defaultProps to work.
export default class MyClass extends Component{ static propTypes = { name: React.PropTypes.string.isRequired, field: React.PropTypes.object.isRequired } static defaultProps = { field: { value: '', errors: [] } } render() {
I have code that relies on this.props.field.value and this.props.field.errors.length , and all my tests explode with TypeError: 'undefined' is not an object (evaluating 'this.props.field.errors.length') , should my default details not give a default value? Initially, my field prop is an empty object.
source share