feat: Optimize connect component props with redux store.

This commit is contained in:
Ahmed Bouhuolia
2020-05-10 02:14:42 +02:00
parent e590a21740
commit a0653674ff
58 changed files with 660 additions and 460 deletions

View File

@@ -6,14 +6,20 @@ import {
getResourceViews,
} from 'store/customViews/customViews.selectors';
const mapStateToProps = (state, props) => ({
accountsViews: getResourceViews(state, 'accounts'),
accounts: getAccountsItems(state, state.accounts.currentViewId),
accountsTypes: state.accounts.accountsTypes,
accountsTableQuery: state.accounts.tableQuery,
accountsLoading: state.accounts.loading,
accountErrors: state.accounts.errors,
});
export default connect(mapStateToProps);
export default (mapState) => {
const mapStateToProps = (state, props) => {
const mapped = {
accountsViews: getResourceViews(state, 'accounts'),
accounts: getAccountsItems(state, state.accounts.currentViewId),
accountsTypes: state.accounts.accountsTypes,
accountsTableQuery: state.accounts.tableQuery,
accountsLoading: state.accounts.loading,
accountErrors: state.accounts.errors,
};
return mapState ? mapState(mapped, state, props) : mapped;
};
return connect(mapStateToProps);
};