Skip to content

Commit 57a7c3c

Browse files
committed
fix: adress debaunce time
1 parent 8c33e24 commit 57a7c3c

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/authz-module/libraries-manager/components/TeamTable/components/SortDropdown.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ const SortDropdown: FC = () => {
3535
const SORT_LABELS: Record<string, string> = useMemo(() => ({
3636
'name-a-z': intl.formatMessage({ id: 'authz.libraries.team.table.sort.name-a-z', defaultMessage: 'Name A-Z' }),
3737
'name-z-a': intl.formatMessage({ id: 'authz.libraries.team.table.sort.name-z-a', defaultMessage: 'Name Z-A' }),
38-
// eslint-disable-next-line react-hooks/exhaustive-deps
39-
}), []);
38+
}), [intl]);
4039

4140
const currentSort = useMemo(() => {
4241
if (!state?.sortBy?.length) { return undefined; }
@@ -63,8 +62,7 @@ const SortDropdown: FC = () => {
6362
...option,
6463
label: SORT_LABELS[key],
6564
})),
66-
// eslint-disable-next-line react-hooks/exhaustive-deps
67-
[],
65+
[SORT_LABELS],
6866
);
6967

7068
const currentSortLabel = sortOrder ? SORT_LABELS[sortOrder] : 'Sort';

src/authz-module/libraries-manager/components/TeamTable/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useMemo } from 'react';
1+
import { useEffect, useMemo } from 'react';
22
import { useNavigate } from 'react-router-dom';
33
import debounce from 'lodash.debounce';
44
import { useIntl } from '@edx/frontend-platform/i18n';
@@ -80,6 +80,10 @@ const TeamTable = () => {
8080
[roles],
8181
);
8282

83+
const fetchData = useMemo(() => debounce(handleTableFetch, 500), [handleTableFetch]);
84+
85+
useEffect(() => () => fetchData.cancel(), [fetchData]);
86+
8387
return (
8488
<DataTable
8589
isFilterable
@@ -90,7 +94,7 @@ const TeamTable = () => {
9094
manualSortBy
9195
defaultColumnValues={{ Filter: TextFilter }}
9296
numBreakoutFilters={3}
93-
fetchData={debounce(handleTableFetch, 1000)}
97+
fetchData={fetchData}
9498
data={rows}
9599
itemCount={teamMembers?.count || 0}
96100
pageCount={pageCount}

0 commit comments

Comments
 (0)