The state of the user rewards to filter.
Optional params: { Optional additional parameters that will be passed along to the
useUserRewards hook.
The returning object contains:
refresh: FetchUserRewardsMethod - Function to refresh or re-fetch the user
rewards data.userRewards: The current list of user rewards.fetched: Boolean indicating whether the user rewards data has been successfully fetched.state and optional additional params to further
refine the data fetch.useUserRewards, passing along
the state.useUserRewards are inherited to optimize network
performance.userRewards state holds the rewards for the project, and
fetched indicates whether the data has been fetched successfully.use userRewards instead
import React, { useEffect } from 'react';
import { useUserRewardsByState } from 'react-playmakers';
const ProjectUserRewards: React.FC = () => {
const { userRewards, fetched, refresh } = useUserRewardsByState('redeemed');
useEffect(() => {
if (!fetched) {
console.log("Fetching rewards for the state...");
}
}, [fetched]);
const handleRefresh = async () => {
await refresh();
console.log("User rewards refreshed.");
};
return (
<div>
{fetched ? (
<div>
<h2>Project User Rewards</h2>
<ul>
{userRewards.map((reward, index) => (
<li key={index}>{reward.name}</li>
))}
</ul>
</div>
) : (
<p>Loading...</p>
)}
<button onClick={handleRefresh}>Refresh Rewards</button>
</div>
);
};
Generated using TypeDoc
Custom React hook to fetch user rewards specific to a given state.
This hook is a wrapper around the useUserRewards hook, automatically passing the
stateto filter user rewards for that state. You can also pass additional parameters to further filter or modify the data fetching behavior.