Skip to content

Commit a4b723b

Browse files
committed
feat(web): add usememo
1 parent 63ce58e commit a4b723b

File tree

1 file changed

+28
-26
lines changed
  • web/src/pages/Cases/CaseDetails/Voting/VotesDetails

1 file changed

+28
-26
lines changed

web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Card, CustomAccordion } from "@kleros/ui-components-library";
2-
import React from "react";
2+
import React, { useMemo } from "react";
33
import styled from "styled-components";
44
import { Answer } from "context/NewDisputeContext";
55
import { DrawnJuror } from "utils/getDrawnJurorsWithCount";
@@ -93,31 +93,33 @@ interface IVotesAccordion {
9393
}
9494

9595
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]);
121123

122124
return (
123125
<>

0 commit comments

Comments
 (0)