I'm trying to set a defaultProp with an object literal, but after some time I realized that the React class constructor is not merging the default props with the applied props, so I end up with undefined values for any properties in the defaultProps literal that haven't been included in the applied props. Is there a way to merge default props and applied props, or do I need to break up my object into several props?
class Test extends React.Component {
constructor(props) {
super(props);
//props.test is only {one: false}
//props.test.two is undefined
}
render() {
return (<div>render</div>)
}
}
Test.defaultProps = {
test: {
one: true,
two: true
}
}
ReactDOM.render(<Test test={{'one': false}}/>, document.getElementById('#test'));