📊
Pollz
  • Introduction
  • Quickstart
  • Guides
    • Initializing your app
    • Create a Poll
    • Vote for a Poll
    • Retrieve a Poll
    • Manage Poll Options
    • Listen to update
    • Anonymous Poll
  • Components
    • React
    • React Native
    • Embedded
  • API Reference
    • init()
    • pollOptions()
      • addOption()
      • deleteOption()
      • renameOption()
    • anonymous
      • createAnonymousToken()
      • getAnonymousPoll()
      • voteAnonymously()
    • polls
      • create()
      • get()
      • getAll()
      • vote()
      • rename()
      • deleteOne()
      • listen()
    • pollTypes
      • getAll()
  • Tooling
    • Typescript
    • React
      • usePoll()
      • usePolls()
      • usePollz()
      • usePollTypes()
      • useAnonymousPoll()
Powered by GitBook
On this page
  • usePollz
  • Parameters
  • Return Values
  • Usage
  1. Tooling
  2. React

usePollz()

usePollz

The usePollz hook is a custom hook provided by the pollz-react package. It allows you to access the Pollz SDK instance and check the initialization status within a React component.

Parameters

The usePollz hook does not take any parameters.

Return Values

The usePollz hook returns an object with the following properties:

  • sdk (PollzSDK): The instance of the Pollz SDK, providing access to all SDK functionalities.

  • initialized (boolean): A boolean value indicating whether the Pollz SDK has been successfully initialized.

Usage

import { usePollz } from 'pollz-react';

const YourComponent = () => {
  const { sdk, initialized } = usePollz();

  if (!initialized) {
    return <div>Loading...</div>;
  }

  // Access sdk to perform Pollz SDK operations

  return (
    <div>
      <h2>Your Pollz Component</h2>
      {/* Render your component with Pollz SDK functionalities */}
    </div>
  );
};
PrevioususePolls()NextusePollTypes()

Last updated 1 year ago