import { ComponentProps, Ref, useContext } from 'react'; import { CompositeItem } from 'reakit/Composite'; import classNames from 'classnames'; import { PaginationContext } from './context'; import { forwardRefWithAs, PropsWithAs } from '../utils'; export interface PaginationButtonProps extends ComponentProps { number?: number; active?: boolean; } function PaginationButtonComponent( { as: Type = 'button', number, children, className, active, disabled, ...props }: PropsWithAs, ref: Ref ) { const { state, currentPage } = useContext(PaginationContext); const isActive = currentPage === number || active; return ( {number || children} ); } export const PaginationButton = forwardRefWithAs< PaginationButtonProps, 'button' >(PaginationButtonComponent);