diff --git a/packages/web-react/src/components/Pagination/PaginationLink.tsx b/packages/web-react/src/components/Pagination/PaginationLink.tsx index c3e53768a7..94180368ab 100644 --- a/packages/web-react/src/components/Pagination/PaginationLink.tsx +++ b/packages/web-react/src/components/Pagination/PaginationLink.tsx @@ -1,18 +1,15 @@ 'use client'; import classNames from 'classnames'; -import React, { ElementType, ForwardedRef, forwardRef } from 'react'; +import React, { ElementType, forwardRef } from 'react'; import { useStyleProps } from '../../hooks'; -import { SpiritPaginationLinkProps } from '../../types'; +import { PolymorphicRef, SpiritPaginationLinkProps } from '../../types'; import { VisuallyHidden } from '../VisuallyHidden'; import { usePaginationStyleProps } from './usePaginationStyleProps'; /* We need an exception for components exported with forwardRef */ /* eslint no-underscore-dangle: ['error', { allow: ['_PaginationLink'] }] */ -const _PaginationLink = ( - props: SpiritPaginationLinkProps, - ref: ForwardedRef, -) => { +const _PaginationLink = (props: SpiritPaginationLinkProps, ref: PolymorphicRef) => { const { elementType: ElementTag = 'a', accessibilityLabel, isCurrent, pageNumber, ...restProps } = props; const { classProps } = usePaginationStyleProps({ isCurrent }); @@ -31,6 +28,6 @@ const _PaginationLink = ( ); }; -export const PaginationLink = forwardRef(_PaginationLink); +const PaginationLink = forwardRef>(_PaginationLink); export default PaginationLink; diff --git a/packages/web-react/src/components/Pagination/UncontrolledPagination.tsx b/packages/web-react/src/components/Pagination/UncontrolledPagination.tsx index fc00ef2abe..8c4f47bdb5 100644 --- a/packages/web-react/src/components/Pagination/UncontrolledPagination.tsx +++ b/packages/web-react/src/components/Pagination/UncontrolledPagination.tsx @@ -1,7 +1,7 @@ 'use client'; import React from 'react'; -import { SpiritUncontrolledPaginationProps } from '../../types/pagination'; +import { ClickEvent, SpiritUncontrolledPaginationProps } from '../../types'; import Pagination from './Pagination'; import PaginationItem from './PaginationItem'; import PaginationLink from './PaginationLink'; @@ -45,7 +45,7 @@ export const UncontrolledPagination = (props: SpiritUncontrolledPaginationProps) href="#" isCurrent={currentPage === pageNumber} pageNumber={pageNumber} - onClick={(event) => { + onClick={(event: ClickEvent) => { event.preventDefault(); handlePageChange(pageNumber); }} diff --git a/packages/web-react/src/components/Pagination/usePagination.tsx b/packages/web-react/src/components/Pagination/usePagination.tsx index 95f13992a1..db14540d6c 100644 --- a/packages/web-react/src/components/Pagination/usePagination.tsx +++ b/packages/web-react/src/components/Pagination/usePagination.tsx @@ -3,7 +3,7 @@ import { UsePaginationProps } from '../../types/pagination'; export const usePagination = ({ totalPages, onChange, defaultPage, visiblePages }: UsePaginationProps) => { const [currentPage, setCurrentPage] = useState(defaultPage <= 0 || defaultPage > totalPages ? 1 : (defaultPage ?? 1)); - const [pages, setPagesArray] = useState([visiblePages] ?? [5]); + const [pages, setPagesArray] = useState([visiblePages]); useMemo(() => { const currentVisiblePages = visiblePages > totalPages ? totalPages : visiblePages;