Skip to content

Commit 9af5cef

Browse files
committed
Deeply merge own component's props with state props.
1 parent 2fd4af7 commit 9af5cef

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/framework/components/PageComposition/Container.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import React from 'react';
2+
import mergeWith from 'lodash/mergeWith';
3+
import isArray from 'lodash/isArray';
24
import { pickInObject, omitInObject } from '../../commons/utilities';
35
import { connect } from 'react-redux';
46
import { bindActionCreators } from 'redux';
@@ -13,6 +15,12 @@ if (process.env.NODE_ENV !== 'production') {
1315
constants = require('../../commons/constants');
1416
}
1517

18+
function mergeCustomizer(objValue, srcValue) {
19+
if (isArray(objValue)) {
20+
return srcValue;
21+
}
22+
}
23+
1624
class Container extends React.Component {
1725
constructor (props, context) {
1826
super(props, context);
@@ -96,7 +104,11 @@ class Container extends React.Component {
96104
} = wrapperPicked;
97105
return React.createElement(
98106
wrappedComponent,
99-
{ ...restPicked, ...wrappedProps, ...this.wrappedHandlers, ...populatedProps, ...stateProps },
107+
mergeWith(
108+
{ ...restPicked, ...wrappedProps, ...this.wrappedHandlers, ...populatedProps},
109+
stateProps,
110+
mergeCustomizer
111+
),
100112
children
101113
);
102114
}

0 commit comments

Comments
 (0)