useAnonymousPoll()
useAnonymousPoll
useAnonymousPoll
The useAnonymousPoll
hook is a custom hook provided by the pollz-react
package. It allows you to fetch an anonymous poll using the provided poll token from the Pollz SDK within a React component.
Parameters
pollToken
(string)
pollToken
(string)The poll token for the anonymous poll you want to fetch.
Return Values
The useAnonymousPoll
hook returns an object with the following properties:
poll
(PollWithOptions | null): The fetched anonymous poll object.null
if the poll is still loading.refetch
(function): A function to manually refetch the anonymous poll data.
Usage
import { useAnonymousPoll } from 'pollz-react';
const YourComponent = ({ pollToken }) => {
const { poll, refetch } = useAnonymousPoll(pollToken);
if (!poll) {
return <div>Loading...</div>;
}
return (
<div>
<h2>Anonymous Poll</h2>
<p>{poll.name}</p>
{/* Render additional anonymous poll details */}
<button onClick={() => refetch()}>Refetch Anonymous Poll</button>
</div>
);
};
Last updated