From f9c7db6bcf1c53c5e423250bc4b8100a328cecd3 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Mon, 20 Sep 2021 11:40:21 +0200 Subject: [PATCH] feat: reset accounts table query once the page unmount. --- client/src/containers/Accounts/AccountsChart.js | 10 +++------- .../containers/Accounts/withAccountsTableActions.js | 6 +++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/client/src/containers/Accounts/AccountsChart.js b/client/src/containers/Accounts/AccountsChart.js index fa8680e0f..af2d627b6 100644 --- a/client/src/containers/Accounts/AccountsChart.js +++ b/client/src/containers/Accounts/AccountsChart.js @@ -25,18 +25,14 @@ function AccountsChart({ accountsTableStateChanged, // #withAccountsActions - setAccountsTableState, + resetAccountsTableState, }) { // Resets the accounts table state once the page unmount. useEffect( () => () => { - setAccountsTableState({ - filterRoles: [], - viewSlug: '', - pageIndex: 0, - }); + resetAccountsTableState(); }, - [setAccountsTableState], + [resetAccountsTableState], ); return ( diff --git a/client/src/containers/Accounts/withAccountsTableActions.js b/client/src/containers/Accounts/withAccountsTableActions.js index ecdbab4a5..42d363992 100644 --- a/client/src/containers/Accounts/withAccountsTableActions.js +++ b/client/src/containers/Accounts/withAccountsTableActions.js @@ -1,8 +1,12 @@ import { connect } from 'react-redux'; -import { setAccountsTableState } from 'store/accounts/accounts.actions'; +import { + setAccountsTableState, + resetAccountsTableState, +} from 'store/accounts/accounts.actions'; const mapActionsToProps = (dispatch) => ({ setAccountsTableState: (queries) => dispatch(setAccountsTableState(queries)), + resetAccountsTableState: () => dispatch(resetAccountsTableState()), }); export default connect(null, mapActionsToProps);