Parameters to customize the API request, such as filters, page, and limit.
The returning object contains:
projects
: Array of fetched projects.fetched
: A boolean flag indicating whether the projects have been fetched.hasMore
: A boolean indicating whether more projects are available to fetch.currentPage
: The current page of the pagination.fetchMore
: ProjectsFetchMoreMethod - Function to fetch the next page of projects
or refresh the current page.refresh
: ProjectsRefreshMethod - Function to refresh the project list.getProjects
responses are cached for 60 seconds using withCache
to
optimize performance and reduce API calls.useEffect
hook triggers fetchProjects
whenever the params page
value changes.projects
: Holds the list of fetched projects.hasMore
: Indicates whether there are more projects to fetch.fetched
: Tracks whether data fetching is complete.fetchProjects
: Fetches the initial or refreshed list of projects, updating projects
and hasMore
.fetchMore
: Fetches additional pages of projects, either appending them to the current
list or refreshing the last page.appendNextPage
, refreshLastPage
, checkHasMore
) are managed by usePagination
.import { useProjects } from 'react-playmakers';
// Usage with custom parameters
const { projects, currentPage, fetched } = useProjects({ page: 1, limit: 10 });
// Conditional rendering based on fetch status
if (!fetched) {
return <LoadingSpinner />;
}
return (
<div>
<h2>Projects (Page {currentPage})</h2>
{projects.map(project => (
<ProjectCard key={project.id} project={project} />
))}
</div>
);
Generated using TypeDoc
Custom hook to manage the fetching and pagination of project data