Skip to content

Commit

Permalink
Convert setState to a callback form
Browse files Browse the repository at this point in the history
  • Loading branch information
gzdunek committed Oct 28, 2024
1 parent f7f2d93 commit 56e1cb8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions web/packages/design/src/DataTable/useTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,30 +185,30 @@ export default function useTable<T>({
if (serversideProps) {
fetching?.onFetchNext?.();
}
setState({
...state,
pagination: state.pagination
setState(prevState => ({
...prevState,
pagination: prevState.pagination
? {
...state.pagination,
currentPage: state.pagination.currentPage + 1,
...prevState.pagination,
currentPage: prevState.pagination.currentPage + 1,
}
: undefined,
});
}));
}

function prevPage() {
if (serversideProps) {
fetching?.onFetchPrev?.();
}
setState({
...state,
pagination: state.pagination
setState(prevState => ({
...prevState,
pagination: prevState.pagination
? {
...state.pagination,
currentPage: state.pagination.currentPage - 1,
...prevState.pagination,
currentPage: prevState.pagination.currentPage - 1,
}
: undefined,
});
}));
}

useEffect(() => {
Expand Down

0 comments on commit 56e1cb8

Please sign in to comment.