Client-side slicing versus server-side fetch for 50k-row table with fixed columns
0 reputation · 24 Feb 2024, 15:26 UTC
0 reputation · 24 Feb 2024, 15:26 UTC
Display a 50,000-row dataset in an Ant Design Table while keeping the browser heap under 150 MB and preserving fixed left columns for horizontal scrolling.
Client-side pagination with the pagination prop and a full dataSource array is simple to implement, but the entire dataset remains in memory. Server-side pagination via onChange fetches only the current page, reducing memory, yet requires a backend endpoint and controlled current/pageSize state. Virtual scrolling (virtual prop) would minimize DOM nodes but is documented as incompatible with fixed columns, rowSpan, and colSpan, which are required here. The installed Ant Design version is 5.x, where onChange receives (page, pageSize) and a pageSize change typically resets to page 1, but this reset behavior can differ when pagination is fully controlled.
current and pageSize in sync with onChange without triggering an extra render loop when the page size changes?Server‑side pagination with a controlled current and pageSize state is the only practical way to keep the browser heap below 150 MB while showing a 50 000‑row Ant Design table with fixed left columns.
rowSpan and colSpan are required.Use a single state object:
const [tableState, setTableState] = useState({ current: 1, pageSize: 100 });
When onChange receives (page, size):
const newCurrent = (size !== tableState.pageSize) ? 1 : page;.setTableState({ current: newCurrent, pageSize: size });.current and pageSize from tableState to request the appropriate slice from the backend.The single setTableState update changes both values atomically, so React processes one render pass instead of two separate updates that would occur if you set current and pageSize independently.
Please confirm whether Ant Design 5.x’s onChange resets current to 1 whenever pageSize changes in a controlled table.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.