Optional parameters to customize the schema fetch behavior (e.g., page
, limit
).
The object conatining:
schemas
: The list of schemas currently fetched and managed by the hook.fetched
: Boolean indicating whether the schemas have been fetched.hasMore
: Boolean indicating whether more schemas are available for pagination.currentPage
: The current page number for pagination.fetchMore
: SchemaFetchMoreMethod - Function to fetch the next page of schemas or
refresh the current page.refresh
: SchemaFetchMethod - Function to refresh the list of schemas.import { useSchemas } from 'react-playmakers';
function SchemasList() {
const {
schemas,
fetched,
hasMore,
currentPage,
fetchMore,
refresh
} = useSchemas({ limit: 10, page: 1 });
if (!fetched) {
return <div>Loading schemas...</div>;
}
return (
<div>
<h1>Schemas (Page {currentPage})</h1>
{schemas.length === 0 ? (
<p>No schemas found.</p>
) : (
<ul>
{schemas.map((schema) => (
<li key={schema.id}>
{schema.title}
<button onClick={() => schema.pushState('open')}>Open</button>
<button onClick={() => schema.pushState('closed')}>Close</button>
<button onClick={() => schema.delete()}>Delete</button>
</li>
))}
</ul>
)}
{hasMore && (
<button onClick={() => fetchMore()}>Load More</button>
)}
<button onClick={() => refresh()}>Refresh Schemas</button>
</div>
);
}
Generated using TypeDoc
Custom React hook to fetch and manage schemas with pagination, including actions like updating and deleting schemas.