From a0c181e0f24de7f3b65db35ecae3f97e2df4ba71 Mon Sep 17 00:00:00 2001 From: Dave Falke Date: Wed, 17 May 2023 14:14:36 -0400 Subject: [PATCH] Memoize options getters in boxplot viz (#228) --- .../implementations/BoxplotVisualization.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/libs/eda/src/lib/core/components/visualizations/implementations/BoxplotVisualization.tsx b/packages/libs/eda/src/lib/core/components/visualizations/implementations/BoxplotVisualization.tsx index b293614340..3d340d3fb3 100755 --- a/packages/libs/eda/src/lib/core/components/visualizations/implementations/BoxplotVisualization.tsx +++ b/packages/libs/eda/src/lib/core/components/visualizations/implementations/BoxplotVisualization.tsx @@ -241,11 +241,16 @@ function BoxplotViz(props: VisualizationProps) { const findEntityAndVariable = useFindEntityAndVariable(filters); - const providedXAxisVariable = options?.getXAxisVariable?.( - computation.descriptor.configuration + const { getXAxisVariable, getComputedYAxisDetails } = options ?? {}; + const { configuration: computeConfig } = computation.descriptor; + + const providedXAxisVariable = useMemo( + () => getXAxisVariable?.(computeConfig), + [computeConfig, getXAxisVariable] ); - const computedYAxisDetails = options?.getComputedYAxisDetails?.( - computation.descriptor.configuration + const computedYAxisDetails = useMemo( + () => getComputedYAxisDetails?.(computeConfig), + [computeConfig, getComputedYAxisDetails] ); // When we only have a computed y axis (and no provided x axis) then the y axis var