This is documentation for the release candidate Stream Chat React Native SDK v7. For the latest stable version, see the latest version (v6).

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.

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);
© Getstream.io, Inc. All Rights Reserved.