Optional
submissionId: stringThe ID of the submission for which votes are managed.
The object containing:
cancelVote
: Cancels the current vote for a given submission.downVote
: Registers a downvote for a given submission.upVote
: Registers an upvote for a given submission.fetched
: A boolean flag indicating whether the vote status has been fetched.myVote
: Represents the current user's vote value.voteBalance
: Represents the total vote balance (sum of all votes) for the submission.useAuth
hook to access the authenticated
user's data to determine the current vote status.import { useVote } from 'react-playmakers';
function SubmissionVoting('SXXXXXXXX') {
const {
upVote,
downVote,
cancelVote,
fetched,
myVote,
voteBalance
} = useVote(submissionId);
if (!fetched) {
return <div>Loading vote data...</div>;
}
return (
<div>
<p>Vote Balance: {voteBalance}</p>
<p>My Vote: {myVote === 1 ? 'Up' : myVote === -1 ? 'Down' : 'None'}</p>
<button
onClick={() => upVote()}
disabled={myVote === 1}
>
Upvote
</button>
<button
onClick={() => downVote()}
disabled={myVote === -1}
>
Downvote
</button>
<button
onClick={() => cancelVote()}
disabled={myVote === 0}
>
Cancel Vote
</button>
</div>
);
}
Generated using TypeDoc
Custom React hook for managing votes on a submission.