Parameters to pass to the API request.
The returning object contains:
questTypes
: An array of quest type objects representing the fetched quest types.fetched
: Boolean indicating whether the quest types has been successfully
fetched.refresh
: FetchQuestTypeMethod - Function to refetch the quest types.getQuestTypes
responses are cached for 5 minutes (300,000 ms) using
withCache
, reducing redundant API calls.useEffect
hook triggers fetchQuestTypes
whenever params
change, ensuring the list is always up to date.fetchQuestTypes
: Fetches quest types based on the provided params
. A quiet
flag can
suppress loading state updates.import { useQuestTypes } from 'react-playmakers';
// Use the hook within a functional component
const QuestTypes = () => {
const { questTypes, fetched, refresh } = useQuestTypes({ region: 'north' });
useEffect(() => {
if (fetched) {
console.log("Quest types fetched:", questTypes);
}
}, [fetched]);
return (
<div>
{fetched ? (
<ul>
{questTypes.map((quest) => (
<li key={quest.id}>{quest.name}</li>
))}
</ul>
) : (
<p>Loading quest types...</p>
)}
<button onClick={() => refresh(true)}>Refresh</button>
</div>
);
};
Generated using TypeDoc
Custom React hook to manage quest types.