|
1 | 1 | import { Card, CustomAccordion } from "@kleros/ui-components-library"; |
2 | | -import React from "react"; |
| 2 | +import React, { useMemo } from "react"; |
3 | 3 | import styled from "styled-components"; |
4 | 4 | import { Answer } from "context/NewDisputeContext"; |
5 | 5 | import { DrawnJuror } from "utils/getDrawnJurorsWithCount"; |
@@ -93,31 +93,33 @@ interface IVotesAccordion { |
93 | 93 | } |
94 | 94 |
|
95 | 95 | const VotesAccordion: React.FC<IVotesAccordion> = ({ drawnJurors, period, answers, isActiveRound }) => { |
96 | | - const accordionItems = drawnJurors |
97 | | - .map((drawnJuror) => |
98 | | - !isUndefined(drawnJuror.vote?.justification?.choice) |
99 | | - ? { |
100 | | - title: ( |
101 | | - <AccordionTitle |
102 | | - juror={drawnJuror.juror.id} |
103 | | - voteCount={drawnJuror.voteCount} |
104 | | - choice={drawnJuror.vote?.justification?.choice} |
105 | | - period={period} |
106 | | - answers={answers} |
107 | | - isActiveRound={isActiveRound} |
108 | | - /> |
109 | | - ), |
110 | | - body: ( |
111 | | - <AccordionContent |
112 | | - justification={drawnJuror?.vote?.justification.reference ?? ""} |
113 | | - choice={drawnJuror.vote?.justification?.choice} |
114 | | - answers={answers} |
115 | | - /> |
116 | | - ), |
117 | | - } |
118 | | - : null |
119 | | - ) |
120 | | - .filter((item) => item !== null); |
| 96 | + const accordionItems = useMemo(() => { |
| 97 | + return drawnJurors |
| 98 | + .map((drawnJuror) => |
| 99 | + !isUndefined(drawnJuror.vote?.justification?.choice) |
| 100 | + ? { |
| 101 | + title: ( |
| 102 | + <AccordionTitle |
| 103 | + juror={drawnJuror.juror.id} |
| 104 | + voteCount={drawnJuror.voteCount} |
| 105 | + choice={drawnJuror.vote?.justification?.choice} |
| 106 | + period={period} |
| 107 | + answers={answers} |
| 108 | + isActiveRound={isActiveRound} |
| 109 | + /> |
| 110 | + ), |
| 111 | + body: ( |
| 112 | + <AccordionContent |
| 113 | + justification={drawnJuror?.vote?.justification.reference ?? ""} |
| 114 | + choice={drawnJuror.vote?.justification?.choice} |
| 115 | + answers={answers} |
| 116 | + /> |
| 117 | + ), |
| 118 | + } |
| 119 | + : null |
| 120 | + ) |
| 121 | + .filter((item) => item !== null); |
| 122 | + }, [drawnJurors, period, answers, isActiveRound]); |
121 | 123 |
|
122 | 124 | return ( |
123 | 125 | <> |
|
0 commit comments