Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/hooks/src/useAntdTable/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,19 @@ describe('useAntdTable', () => {
await waitFor(() => expect(hook.result.current.tableProps.pagination.total).toBe(20));
});

test('should defaultCurrent work', async () => {
queryArgs = undefined;
form.resetFields();
changeSearchType('simple');

act(() => {
hook = setUp(asyncFn, { defaultCurrent: 2 });
});

await waitFor(() => expect(queryArgs.current).toBe(2));
expect(queryArgs.pageSize).toBe(10);
});

test('should defaultParams work', async () => {
queryArgs = undefined;
form.resetFields();
Expand Down
4 changes: 2 additions & 2 deletions packages/hooks/src/useAntdTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const useAntdTable = <TData extends Data, TParams extends Params>(
const pagination = initPagination || {
pageSize: options.defaultPageSize || 10,
...(params?.[0] || {}),
current: 1,
current: options.defaultCurrent || 1,
};
if (!form) {
// @ts-ignore
Expand Down Expand Up @@ -176,7 +176,7 @@ const useAntdTable = <TData extends Data, TParams extends Params>(
? undefined
: {
pageSize: options.defaultPageSize || options.defaultParams?.[0]?.pageSize || 10,
current: 1,
current: options.defaultCurrent || 1,
...(defaultParams?.[0] || {}),
},
);
Expand Down
Loading