dane-brown / react-sanity-pagination Goto Github PK
View Code? Open in Web Editor NEWReact pagination for Sanity.io
Home Page: https://0pzik.codesandbox.io/
React pagination for Sanity.io
Home Page: https://0pzik.codesandbox.io/
The output this generates is an unordered list with a bunch of nested buttons. Each button should be within a list-item.
current output:
<ul class="pagePagination">
<button class="paginateButton paginationPrev">⬅️</button>
<button class="">1</button>
<button class="">2</button>
<button class="">3</button>
<button class="active">4</button>
<button class="paginateButton paginationNext" disabled="">➡️</button>
</ul>
Should be:
<ul class="pagePagination">
<li><button class="paginateButton paginationPrev">⬅️</button></li>
<li><button class="">1</button></li>
<li><button class="">2</button></li>
<li><button class="">3</button></li>
<li><button class="active">4</button></li>
<li><button class="paginateButton paginationNext" disabled="">➡️</button></li>
</ul>
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.description}
Read Post{/* Props required: action, postsPerPage, postsLength */}
<Pagination
paginationStyle={"centerMode"}
items={itemsToSend}
action={action}
postsPerPage={postsPerPage}
nextButton={true}
prevButton={true}
nextButtonLabel={"👉🏻"}
prevButtonLabel={"👈🏻"}
/>
Explore implementing pagination dots where certain page buttons get hidden if the list of pages is too long.
Example: 1 2 3 ... 6 7 8
Hi
Is is possible to upgrade it to react 18 ?
Or is there a work around it
Thank you
Regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.