Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f2ff14a commit 37e1701Copy full SHA for 37e1701
site/src/hooks/usePagination.ts
@@ -9,7 +9,7 @@ export const usePagination = ({
9
const [searchParams, setSearchParams] = searchParamsResult;
10
const page = searchParams.get("page") ? Number(searchParams.get("page")) : 1;
11
const limit = DEFAULT_RECORDS_PER_PAGE;
12
- const offset = calcOffset(page, limit);
+ const offset = page <= 0 ? 0 : (page - 1) * limit;
13
14
const goToPage = (page: number) => {
15
searchParams.set("page", page.toString());
@@ -23,7 +23,3 @@ export const usePagination = ({
23
offset,
24
};
25
26
-
27
-export const calcOffset = (page: number, limit: number) => {
28
- return page <= 0 ? 0 : (page - 1) * limit;
29
-};
0 commit comments