Skip to content

Commit

Permalink
change hooks order execution when sorting (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalogrosz committed Jun 13, 2021
1 parent 632f892 commit 074a676
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ function DataTable<T extends RowRecord>(props: TableProps<T>): JSX.Element {
onSelectedRowsChange({ allSelected, selectedCount, selectedRows });
}, [selectedCount]);

useDidUpdateEffect(() => {
onSort(selectedColumn, sortDirection);
}, [selectedColumn, sortDirection]);

useDidUpdateEffect(() => {
onChangePage(currentPage, paginationTotalRows || rows.length);
}, [currentPage]);
Expand All @@ -253,10 +257,6 @@ function DataTable<T extends RowRecord>(props: TableProps<T>): JSX.Element {
onChangeRowsPerPage(rowsPerPage, currentPage);
}, [rowsPerPage]);

useDidUpdateEffect(() => {
onSort(selectedColumn, sortDirection);
}, [selectedColumn, sortDirection]);

useDidUpdateEffect(() => {
handleChangePage(paginationDefaultPage);
}, [paginationDefaultPage, paginationResetDefaultPage]);
Expand Down

0 comments on commit 074a676

Please sign in to comment.