Parameters to pass to the API request.
The returning object contains:
categories
: An array of string objects representing the fetched quest type categories.fetched
: Boolean indicating whether the quest type has been successfully
fetched.refresh
: FetchQuestTypeCategoriesMethod - Function to refetch the quest type
categories.getQuestTypeCategories
responses are cached for 5 minutes (300,000 ms) using
withCache
. Cache is cleared when refresh
is triggered.useEffect
hook triggers fetchQuestTypeCategories
whenever
params
change, ensuring the category list is up to date.fetchQuestTypeCategories
: Fetches categories based on params
, with options for a
quiet mode and cache bypass (refresh
).import { useQuestTypeCategories } from 'react-playmakers';
const CategoriesComponent = () => {
const { categories, fetched, refresh } = useQuestTypeCategories({ type: 'adventure' });
useEffect(() => {
if (fetched) {
console.log("Quest type categories fetched:", categories);
}
}, [fetched]);
return (
<div>
{fetched ? (
<ul>
{categories.map((category) => (
<li key={category}>{category}</li>
))}
</ul>
) : (
<p>Loading quest type categories...</p>
)}
<button onClick={() => refresh(true)}>Refresh</button>
</div>
);
};
Generated using TypeDoc
Custom React hook to manage quest type.