Optional
params: { Parameters for fetching assets.
The returning object contains:
assets
: An array of extended asset objects.fetched
: Boolean indicating whether the assets have been successfully fetched.hasMore
: Boolean indicating whether there are more assets available to fetch.currentPage
: The current page number of the fetched assets.fetchMore
: AssetsFetchMoreMethod - Function to fetch more assets, typically for pagination.refresh
: AssetsFetchMethod - Function to refresh or re-fetch the assets.import { useAssets } from 'react-playmakers';
const AssetDisplay = () => {
const { assets, fetched, hasMore, fetchMore, refresh } = useAssets({
projectId: "pXXXXXXXX",
tags: ["3D model"],
limit: 10
});
useEffect(() => {
if (!fetched) {
console.log("Fetching assets...");
}
}, [fetched]);
return (
<div>
{assets.map(asset => (
<div key={asset.id}>
<p>{asset.name}</p>
<button onClick={() => asset.delete()}>Delete</button>
</div>
))}
{hasMore && <button onClick={() => fetchMore()}>Load More</button>}
<button onClick={refresh}>Refresh</button>
</div>
);
};
export default AssetDisplay;
Generated using TypeDoc
Custom React hook to fetch and manage assets with pagination and caching support.