UNPKG

@codeperate/app-asset

Version:

Codeperate App Asset

13 lines (12 loc) 497 B
export 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(component, mapState)); _mapStateToProps(component, mapState); return unsubscribe; };