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></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
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/1123c1ff-34cb-436e-b293-725d3df5a927?what_not_in_standard=true)
[](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: [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]