API Reference
Advanced Tutorials
Comparison
FAQ
Contributing
Testing
Migration Guide
Licence
This is documentation for Refine 3.xx.xx, which is no longer actively maintained.
For up-to-date documentation, see the latest version (4.xx.xx).
Version: 3.xx.xx
basic-usage-live-preview
localhost:3000/categories
Live previews only work with the latest documentation.
import React from "react";
import { useInfiniteList } from "@pankod/refine-core";
const PostList = () => {
const {
data,
isError,
isLoading,
hasNextPage,
fetchNextPage,
isFetchingNextPage,
} = useInfiniteList({
resource: "categories",
config: {
pagination: {
pageSize: 4
}
}
});
if (isLoading) {
return <p>Loading</p>;
}
if (isError) {
return <p>Something went wrong</p>;
}
const allPages = [].concat(...(data?.pages ?? []).map((page) => page.data));
return (
<div>
<ul>
{allPages.map(({ id, title }) => (
<li key={id}>
{id}.{title}
</li>
))}
</ul>
{
hasNextPage && (
<button
onClick={() => fetchNextPage()}
disabled={isFetchingNextPage}
>
{isFetchingNextPage ? "Loading more..." : "Load More" }
</button>
)
}
</div>
);
}