diff --git a/web/packages/design/src/DataTable/useTable.ts b/web/packages/design/src/DataTable/useTable.ts index 3dc86ed96707d..e8c70f3bd2dd0 100644 --- a/web/packages/design/src/DataTable/useTable.ts +++ b/web/packages/design/src/DataTable/useTable.ts @@ -185,30 +185,30 @@ export default function useTable({ 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(() => {