Skip to content

Commit 35b0cd3

Browse files
committed
Simplify pagination widget
1 parent b7edc7a commit 35b0cd3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

site/src/components/PaginationWidget/PaginationWidget.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import { useActor } from "@xstate/react"
77
import { ChooseOne, Cond } from "components/Conditionals/ChooseOne"
88
import { Maybe } from "components/Conditionals/Maybe"
99
import { CSSProperties } from "react"
10-
import { useSearchParams } from "react-router-dom"
1110
import { PaginationMachineRef } from "xServices/pagination/paginationXService"
1211
import { PageButton } from "./PageButton"
13-
import { buildPagedList, getInitialPage } from "./utils"
12+
import { buildPagedList } from "./utils"
1413

1514
export type PaginationWidgetProps = {
1615
prevLabel?: string
@@ -32,8 +31,7 @@ export const PaginationWidget = ({
3231
const styles = useStyles()
3332
const [paginationState, send] = useActor(paginationRef)
3433

35-
const [searchParams, _] = useSearchParams()
36-
const currentPage = getInitialPage(searchParams.get("page"))
34+
const currentPage = paginationState.context.page
3735
const numRecordsPerPage = paginationState.context.limit
3836

3937
const numPages = numRecords ? Math.ceil(numRecords / numRecordsPerPage) : 0

0 commit comments

Comments
 (0)