@codeperate/app-asset
Version:
Codeperate App Asset
15 lines (13 loc) • 485 B
JavaScript
const mapStateToProps = (store, component, mapState) => {
const _mapStateToProps = (_component, _mapState) => {
const mergeProps = mapState(store.getState());
Object.keys(mergeProps).forEach(newPropName => {
const newPropValue = mergeProps[newPropName];
component[newPropName] = newPropValue;
});
};
const unsubscribe = store.subscribe(() => _mapStateToProps());
_mapStateToProps();
return unsubscribe;
};
export { mapStateToProps as m };