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>
  );
};

Last updated