usePoll()
usePoll
usePoll
The usePoll
hook is a custom hook provided by the pollz-react
package. It allows you to fetch and manage real-time updates for a specific poll from the Pollz SDK within a React component.
Parameters
pollId
(EntryIdType)
pollId
(EntryIdType)The unique identifier of the poll you want to fetch and listen to updates for.
options
(optional)
options
(optional)An object with the following optional properties:
listen
(boolean): Whether to set up a real-time listener for updates. Default isfalse
.orderOptionsBy
(OrderBy): The order in which to retrieve poll options for the updated poll. Default isOrderBy.Asc
(ascending).
Return Values
The usePoll
hook returns an object with the following properties:
poll
(PollWithOptions | null): The fetched poll object.null
if the poll is still loading.refetch
(function): A function to manually refetch the poll data.
Example
The usePoll
hook provides an easy way to integrate specific poll data into your React components, with support for real-time updates. Customize the hook based on your application's needs.
Last updated