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

@@ -7,20 +7,22 @@ import {
getCurrentPageResults
} from 'store/selectors';
export const mapStateToProps = (state, props) => {
const viewPages = getViewPages(state.items.views, state.items.currentViewId);
return {
itemsViews: getResourceViews(state, 'items'),
itemsCurrentPage: getCurrentPageResults(
state.items.items,
viewPages,
state.items.currentPage,
),
itemsBulkSelected: state.items.bulkActions,
itemsTableLoading: state.items.loading,
itemsTableQuery: state.items.tableQuery,
export default (mapState) => {
const mapStateToProps = (state, props) => {
const viewPages = getViewPages(state.items.views, state.items.currentViewId);
const mapped = {
itemsViews: getResourceViews(state, 'items'),
itemsCurrentPage: getCurrentPageResults(
state.items.items,
viewPages,
state.items.currentPage,
),
itemsBulkSelected: state.items.bulkActions,
itemsTableLoading: state.items.loading,
itemsTableQuery: state.items.tableQuery,
};
return mapState ? mapState(mapped, state, props) : mapped;
};
};
export default connect(mapStateToProps);
return connect(mapStateToProps);
};