From 90458fed68cb06a2a65e7ba55c95bbe33dbf83f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 8 Dec 2020 13:06:17 +0100 Subject: [PATCH] cost-insights: fix react-hooks/exhaustive-deps error --- .changeset/friendly-news-know.md | 5 +++++ .../components/ProductInsightsCard/ProductInsightsChart.tsx | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/friendly-news-know.md 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>();