UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

17 lines (16 loc) 982 B
import clsx from 'clsx'; import React from 'react'; import { PollOptionSelector as DefaultPollOptionSelector } from './PollOptionSelector'; import { useStateStore } from '../../store'; import { useComponentContext, usePollContext } from '../../context'; const pollStateSelector = (nextValue) => ({ options: nextValue.options, }); export const PollOptionList = ({ optionsDisplayCount }) => { const { PollOptionSelector = DefaultPollOptionSelector } = useComponentContext(); const { poll } = usePollContext(); const { options } = useStateStore(poll.state, pollStateSelector); return (React.createElement("div", { className: clsx('str-chat__poll-option-list', { 'str-chat__poll-option-list--full': typeof optionsDisplayCount === 'undefined', }) }, options.slice(0, optionsDisplayCount ?? options.length).map((option) => (React.createElement(PollOptionSelector, { displayAvatarCount: 3, key: `poll-option-${option.id}`, option: option }))))); };