diff --git a/.changeset/friendly-news-know.md b/.changeset/friendly-news-know.md new file mode 100644 index 0000000000..521ac5cc28 --- /dev/null +++ b/.changeset/friendly-news-know.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-cost-insights': patch +--- + +fix react-hooks/exhaustive-deps error diff --git a/plugins/cost-insights/src/components/ProductInsightsCard/ProductInsightsChart.tsx b/plugins/cost-insights/src/components/ProductInsightsCard/ProductInsightsChart.tsx index 08a4c5efa2..ace2766277 100644 --- a/plugins/cost-insights/src/components/ProductInsightsCard/ProductInsightsChart.tsx +++ b/plugins/cost-insights/src/components/ProductInsightsCard/ProductInsightsChart.tsx @@ -70,8 +70,10 @@ export const ProductInsightsChart = ({ const layoutClasses = useLayoutStyles(); // Only a single entities Record for the root product entity is supported - const entityLabel = assertAlways(findAnyKey(entity.entities)); - const entities = entity.entities[entityLabel] ?? []; + const entities = useMemo(() => { + const entityLabel = assertAlways(findAnyKey(entity.entities)); + return entity.entities[entityLabel] ?? []; + }, [entity]); const [activeLabel, setActive] = useState>(); const [selectLabel, setSelected] = useState>();