korbit-ai[bot] commented on code in PR #34539:
URL: https://github.com/apache/superset/pull/34539#discussion_r2252311271


##########
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx:
##########
@@ -659,6 +659,10 @@ const FiltersConfigForm = (
     showDataset,
   ]);
 
+  const chartIds = useMemo(() => {
+    return Object.values(charts).map(chart => chart.id);
+  }, [charts]);

Review Comment:
   ### Inefficient useMemo dependency <sub>![category 
Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The useMemo dependency relies on the full 'charts' object reference instead 
of a more stable dependency that would prevent unnecessary recalculations.
   
   
   ###### Why this matters
   When using the entire 'charts' object as a dependency, the memoized value 
will be recalculated whenever any property of the charts object changes, not 
just when the chart IDs change. This can lead to unnecessary recalculations and 
reduced performance.
   
   ###### Suggested change ∙ *Feature Preview*
   Use a more specific dependency by stringifying just the relevant chart IDs:
   ```typescript
   const chartIds = useMemo(() => {
       return Object.values(charts).map(chart => chart.id);
   }, [JSON.stringify(Object.values(charts).map(chart => chart.id))]);
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:03b28621-c208-4e99-a508-9b21f1f0e0db -->
   
   
   [](03b28621-c208-4e99-a508-9b21f1f0e0db)



-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to