From c8b119bb2f3466399d24fe38f2f772969d9ad416 Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Thu, 2 Nov 2023 10:39:59 +0100 Subject: [PATCH] perf: useCallback --- app/charts/combo/chart-combo-line-single.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/charts/combo/chart-combo-line-single.tsx b/app/charts/combo/chart-combo-line-single.tsx index 5c110ae14..49db67896 100644 --- a/app/charts/combo/chart-combo-line-single.tsx +++ b/app/charts/combo/chart-combo-line-single.tsx @@ -83,6 +83,13 @@ export const ChartComboLineSingle = React.memo( const { chartConfig, measures } = props; const { interactiveFiltersConfig } = chartConfig; + const getLegendItemDimension = React.useCallback( + (label) => { + return measures.find((measure) => measure.label === label); + }, + [measures] + ); + return ( @@ -100,9 +107,7 @@ export const ChartComboLineSingle = React.memo( { - return measures.find((measure) => measure.label === label); - }} + getLegendItemDimension={getLegendItemDimension} />