Optional
id: stringThe identifier of the user's quest to fetch. If not provided, the hook does nothing.
The returning object contains:
userQuest
: The current user quest object. It is null
if the
user quest has not been fetched or does not exist.fetched
: Boolean indicating whether the user quest has been successfully
fetched.refresh
: fetchUserQuestMethod - function to refetch the user quest.import { useUserQuest } from 'react-playmakers';
const UserQuestComponent: React.FC = () => {
const { userQuest, fetched, refresh } = useUserQuest('UQXXXXXXX');
useEffect(() => {
if (fetched && userQuest) {
console.log("User quest fetched:", userQuest);
}
}, [fetched, userQuest]);
const handleRefresh = () => {
refresh(true);
};
return (
<div>
<h1>User Quest</h1>
{fetched ? (
userQuest ? (
<div>
<p>Quest Name: {userQuest.name}</p>
<p>Quest Description: {userQuest.description}</p>
</div>
) : (
<p>No quest found.</p>
)
) : (
<p>Loading...</p>
)}
<button onClick={handleRefresh}>Refresh Quest</button>
</div>
);
};
Generated using TypeDoc
Custom React hook to manage and fetch a user's quest data.