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 the release candidate
Stream Chat React Native SDK v6. For the latest stable version, see the latest version (v5).
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: