import { PollVote, PollState } from "stream-chat";
import { usePollStateStore } from "stream-chat-react-native";
type PollOptionSelectorReturnValue = {
latestVotesByOption: Record<string, PollVote[]>;
maxVotedOptionIds: string[];
};
const selector = <
StreamChatGenerics extends
DefaultStreamChatGenerics = DefaultStreamChatGenerics,
>(
nextValue: PollState<StreamChatGenerics>,
): PollOptionSelectorReturnValue => ({
latestVotesByOption: nextValue.latestVotesByOption,
maxVotedOptionIds: nextValue.maxVotedOptionIds,
});
const { latestVotesByOption, maxVotedOptionIds } = usePollStateStore(selector);
This is documentation for
Stream Chat React Native SDK v5, which is nolonger actively maintained. For up-to-date documentation, 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
On this page: