Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagiantion button not calculated automatically #13

Open
BibhabenduMukherjee opened this issue Feb 13, 2023 · 0 comments
Open

Pagiantion button not calculated automatically #13

BibhabenduMukherjee opened this issue Feb 13, 2023 · 0 comments

Comments

@BibhabenduMukherjee
Copy link

BibhabenduMukherjee commented Feb 13, 2023

function BlogDsList() {
const postsPerPage = 4;
const [items, setItems] = useState([]);
useEffect(() => {
client.fetch(*[_type == 'post' && topic =='ds']{ ..., author->, categories[]-> } | order(_createdAt )).then(res => {
itemsToSend.push(...res);
});
}, []);
const action = (page, range, items) => {
console.log(Page: ${page} 📃, Range: ${range} 🚀, Items: ${items} 🌀);
setItems(items);
};

return (

<div className="paginationContent">
  {items.map((post) => {
    return <div key={post._id} className='mt-5 pl-8 cursor-pointer hover:bg-gray-200 p-2 flex flex-col shadow-md rounded-md bg-gray-100 '>

{post._updatedAt}

{post.title}

{post.description}

Read Post
; })}
{/* Props required: action, postsPerPage, postsLength */}
<Pagination
    paginationStyle={"centerMode"}
    items={itemsToSend}
    action={action}
    postsPerPage={postsPerPage}
    nextButton={true}
    prevButton={true}
    nextButtonLabel={"👉🏻"}
    prevButtonLabel={"👈🏻"}
  />
) } I have this above component That shows some post.But in my case pagination button are not calculated perfectly example i have 8 post if i want that 4 post should be render in one page so the total page should be 2(max) it can't go beyond that but in my case i have 4 tab some repeated data shows. Please help me out 🙏🏻
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant