Skip to content

Commit

Permalink
perf: useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Nov 2, 2023
1 parent ecba93e commit c8b119b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/charts/combo/chart-combo-line-single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ComboLineSingleChart aspectRatio={0.4} {...props}>
<ChartContainer>
Expand All @@ -100,9 +107,7 @@ export const ChartComboLineSingle = React.memo(
<LegendColor
chartConfig={chartConfig}
symbol="line"
getLegendItemDimension={(label) => {
return measures.find((measure) => measure.label === label);
}}
getLegendItemDimension={getLegendItemDimension}
/>
</ChartControlsContainer>
</ComboLineSingleChart>
Expand Down

0 comments on commit c8b119b

Please sign in to comment.