Info:
This is documentation for Stream Chat React Native SDK v8, which is no longer actively maintained. For up-to-date documentation, see the latest version (v9).

usePollStateStore

A utility hook used to access the poll state store directly by passing a selector.

The full extent of the Poll state can be found here, under the PollState type.

This hook can only be used within a child of PollContext.

Best Practices

  • Use selectors to limit re-renders to only the state you need.
  • Keep selectors pure and stable for predictable updates.
  • Use this hook only inside PollContext children.
  • Prefer usePollState for simple cases; use this for advanced state access.
  • Handle missing or partial poll state gracefully.

Example usage

import { PollVote, PollState } from "stream-chat";
import { usePollStateStore } from "stream-chat-react-native";

type PollOptionSelectorReturnValue = {
  latestVotesByOption: Record<string, PollVote[]>;
  maxVotedOptionIds: string[];
};

const selector = (nextValue: PollState): PollOptionSelectorReturnValue => ({
  latestVotesByOption: nextValue.latestVotesByOption,
  maxVotedOptionIds: nextValue.maxVotedOptionIds,
});

const { latestVotesByOption, maxVotedOptionIds } = usePollStateStore(selector);
Add Chat to my app: getstream.io/SKILL.md

The fastest way to build with Stream. Start a new project or improve an existing one. Full CLI and documentation integration out of the box.


Ask your agent:

/stream Build me a Social App with Feeds and Moderation.
/stream Any livestream calls running?
/stream Chat React Native v8: <Your Question>