[FIX] store: properly handle defaultProps in connected components

Thanks to aku for issue + tests + first solution

closes #245
This commit is contained in:
Géry Debongnie
2019-07-16 14:17:37 +02:00
parent b1d022b583
commit 93d0a7dd46
3 changed files with 159 additions and 3 deletions
+5 -2
View File
@@ -52,15 +52,18 @@ export class ConnectedComponent<T extends Env, P, S> extends Component<T, P, S>
}
constructor(parent, props?: any) {
super(parent, props);
const store = this.getStore(this.env);
const ownProps = Object.assign({}, props || {});
const ownProps = this.props || {};
const storeProps = (<any>this.constructor).mapStoreToProps(
store.state,
ownProps,
store.getters
);
const mergedProps = Object.assign({}, props || {}, storeProps);
const mergedProps = Object.assign({}, ownProps, storeProps);
this.props = mergedProps;
(<any>this.__owl__).ownProps = ownProps;
(<any>this.__owl__).currentStoreProps = storeProps;
(<any>this.__owl__).store = store;