Optional
id: stringThe ID of the reward type to fetch. If not provided, the hook will not fetch data.
The returning object contains:
refresh
: FetchRewardTypeMethod - Function to refresh the reward type data.rewardType
: The current reward type or null
if not yet fetched.fetched
: Boolean indicating whether the reward type has been fetched.useEffect
hook is used to initiate the data fetch when the id
changes.import { useRewardType } from "react-playmakers";
const RewardTypeComponent = () => {
const { rewardType, fetched, refresh } = useRewardType("RXXXXXXX");
return (
<div>
{fetched ? (
<div>
<h1>Reward Type</h1>
{rewardType ? (
<p>{rewardType.name}</p>
) : (
<p>No reward type found</p>
)}
<button onClick={() => refresh()}>Refresh</button>
</div>
) : (
<p>Loading...</p>
)}
</div>
);
};
Generated using TypeDoc
A custom hook to fetch and manage a specific reward type by its ID.
This hook provides a way to fetch, refresh, and track the state of a reward type using the provided API method. The data is cached for performance and efficiency.