mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Display agent version in pages #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
24
web/src/hooks/logic-hooks/use-pagination.ts
Normal file
24
web/src/hooks/logic-hooks/use-pagination.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
export function useClientPagination(list: Array<any>) {
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(10);
|
||||
|
||||
const onPaginationChange = useCallback((page: number, pageSize: number) => {
|
||||
setPage(page);
|
||||
setPageSize(pageSize);
|
||||
}, []);
|
||||
|
||||
const pagedList = useMemo(() => {
|
||||
return list?.slice((page - 1) * pageSize, page * pageSize);
|
||||
}, [list, page, pageSize]);
|
||||
|
||||
return {
|
||||
page,
|
||||
pageSize,
|
||||
setPage,
|
||||
setPageSize,
|
||||
onPaginationChange,
|
||||
pagedList,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user