Optional
id: stringOptional project ID. If provided, the hook will fetch the project with this ID.
The returning object contains:
fetched
: Boolean indicating if the project has been fetchedproject
: The current project data.push
: ProjectPushMethod - Function to push changes to the project, updating the
project data on the server.pushThumbnail
: ProjectPushThumbnailMethod - Function to update the project's thumbnail.refresh
: ProjectFetchMethod - Function to manually refresh the project data.setConfig
: Function to locally update the project configuration state.setThumbnail
: Function to set a new thumbnail file in the state.updateConfig
: ProjectUpdateConfigMethod - Function to update the project's configuration on the server.
It also updates the project's configuration in the local state and update the updatedAt
field.pushNewOwner
: ProjectPushNewOwnerMethod - Function for transferring ownership of
the project to a new owner.updateMembers
: ProjectUpdateMembersMethod - Function for updating the project's members.getProject
responses are cached for 60 seconds using the withCache
utility
to reduce redundant API calls.useEffect
hook triggers fetchProject
when projectId
changes
keeping the project data in sync.updateConfig
: Updates the project's configuration and clears cached data.pushThumbnail
: Uploads a new thumbnail and clears cached data.pushProject
: Validates input, creates or updates the project, handles configuration
thumbnail updates, and clears cache.Example using the useProject
hook with in a component with a Demo project ID to fetch and
display project details.
import { useProject } from 'react-playmakers';
export default function ProjectComponent(){
// Fetch project details using Demo project ID
const { project } = useProject('piNhGEaTE');
// Display project's name
return (
<div>
<h1>{project?.name}</h1>
</div>
);
}
Generated using TypeDoc
A custom hook for managing project-related operations.