If itemRender is defined and backward is specified, it will not be displayed correctly.
The rightRender is passed in src/components/pagination.tsx:L153
, but I think it should be leftRender.
The example below will appear as shown in the picture.
import { Button, forwardRef } from "@chakra-ui/react"
import ChocPaginator from "@choc-ui/paginator"
import React, { ComponentProps } from "react"
type ItemRenderFn = ComponentProps<typeof ChocPaginator>["itemRender"]
const PrevButton = forwardRef((props, ref) => (
<Button ref={ref} {...props}>
Prev
</Button>
))
const NextButton = forwardRef((props, ref) => (
<Button ref={ref} {...props}>
Next
</Button>
))
const BackwardButton = forwardRef((props, ref) => (
<Button ref={ref} {...props}>
Backward
</Button>
))
const ForwardButton = forwardRef((props, ref) => (
<Button ref={ref} {...props}>
Forward
</Button>
))
export const Pagination: React.FC = () => {
const itemRender: ItemRenderFn = (_, type) => {
if (type === "prev") return PrevButton
if (type === "next") return NextButton
// This will not be rendered.
if (type === "backward") return BackwardButton
if (type === "forward") return ForwardButton
}
return (
<ChocPaginator
colorScheme="blue"
defaultCurrent={5}
itemRender={itemRender}
pageSize={10}
paginationProps={{
display: "flex",
}}
total={500}
/>
)
}
I tried to fix it, but gave up because it fails to test on the master branch.
Would be great to see this fixed.