Skip to content

Commit

Permalink
change hooks order execution when sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
lalogrosz committed May 26, 2021
1 parent 61b1d3f commit 6faf952
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 @@ -246,6 +246,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 @@ -254,10 +258,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 6faf952

Please sign in to comment.