Skip to content

Commit 1b2afd8

Browse files
committed
fix: convert PollVote to component
1 parent 179c35a commit 1b2afd8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

package/src/components/Poll/components/PollResults/PollOptionFullResults.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type PollOptionFullResultsProps<
2424
};
2525

2626
export const PollOptionFullResultsItem = ({ item }: { item: PollVoteClass }) => (
27-
<PollVote {...item} />
27+
<PollVote vote={item} />
2828
);
2929

3030
export const PollOptionFullResultsContent = ({

package/src/components/Poll/components/PollResults/PollResultItem.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type PollResultItemProps<
1616
option: PollOption<StreamChatGenerics>;
1717
};
1818

19-
export const PollVote = (vote: PollVoteClass) => {
19+
export const PollVote = ({ vote }: { vote: PollVoteClass }) => {
2020
const { t, tDateTimeParser } = useTranslationContext();
2121
const { votingVisibility } = usePollState();
2222
const {
@@ -47,7 +47,7 @@ export const PollVote = (vote: PollVoteClass) => {
4747
);
4848

4949
return (
50-
<View key={`results_vote_${vote.id}`} style={[styles.voteContainer, container]}>
50+
<View style={[styles.voteContainer, container]}>
5151
<View style={{ flexDirection: 'row' }}>
5252
{!isAnonymous && vote.user?.image ? (
5353
<Avatar image={vote.user.image as string} key={vote.id} size={20} />
@@ -61,6 +61,10 @@ export const PollVote = (vote: PollVoteClass) => {
6161
);
6262
};
6363

64+
const PollResultsVoteItem = (vote: PollVoteClass) => (
65+
<PollVote key={`results_vote_${vote.id}`} vote={vote} />
66+
);
67+
6468
export const PollResultsItem = ({ option }: PollResultItemProps) => {
6569
const { t } = useTranslationContext();
6670
const { latestVotesByOption, voteCountsByOption } = usePollState();
@@ -86,7 +90,7 @@ export const PollResultsItem = ({ option }: PollResultItemProps) => {
8690
</View>
8791
{latestVotesByOption?.[option.id]?.length > 0 ? (
8892
<View style={{ marginTop: 16 }}>
89-
{(latestVotesByOption?.[option.id] ?? []).slice(0, 5).map(PollVote)}
93+
{(latestVotesByOption?.[option.id] ?? []).slice(0, 5).map(PollResultsVoteItem)}
9094
</View>
9195
) : null}
9296
<ShowAllVotesButton option={option} />

0 commit comments

Comments
 (0)