kgabryje commented on code in PR #36062:
URL: https://github.com/apache/superset/pull/36062#discussion_r2542597898


##########
superset-frontend/src/chartCustomizations/components/DeckglLayerVisibility/DeckglLayerVisibilityCustomizationPlugin.tsx:
##########
@@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { useEffect, useState, useMemo, useRef } from 'react';
+import { t, QueryFormData, DataMask, ExtraFormData } from '@superset-ui/core';
+import { useTheme } from '@apache-superset/core/ui';
+import {
+  Select,
+  FormItem,
+  Tooltip,
+  Icons,
+  Flex,
+} from '@superset-ui/core/components';
+import { useSelector } from 'react-redux';
+import { PluginDeckglLayerVisibilityProps } from './types';
+import { useDeckLayerMetadata } from './useDeckLayerMetadata';
+import { FilterPluginStyle } from '../common';
+
+type ChartState = {
+  form_data?: QueryFormData;
+  [key: string]: unknown;
+};
+
+type StateWithCharts = {
+  charts: Record<string, ChartState>;
+};
+
+type DataMaskState = Record<
+  string,
+  DataMask & {
+    extraFormData?: ExtraFormData & { visible_deckgl_layers?: number[] };
+  }
+>;
+
+export default function DeckglLayerVisibilityCustomizationPlugin(
+  props: PluginDeckglLayerVisibilityProps,
+) {
+  const { formData, filterState, setDataMask, width, height } = props;
+  const theme = useTheme();
+  const [hiddenLayers, setHiddenLayers] = useState<number[]>(
+    filterState?.value || [],
+  );
+  const hasInitialized = useRef(false);
+
+  const charts = useSelector((state: StateWithCharts) => state.charts);

Review Comment:
   Selecting the whole charts objects will lead to thousands of rerenders, as 
this component will rerender every time ANY chart ono the dashboard changes. 
For example, if there are 50 charts, and they change their status 'loading' -> 
'success' -> 'rendered', that's 150 rerenders just on init, + more when query 
is triggered, form data is set etc.
   Since we only really need form_data here, I'd suggest using 
`state.sliceEntites.slices`, those are more static



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to