cost-insights: fix react-hooks/exhaustive-deps error

This commit is contained in:
Fredrik Adelöw
2020-12-08 13:06:17 +01:00
parent 1e50e1f853
commit 90458fed68
2 changed files with 9 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-cost-insights': patch
---
fix react-hooks/exhaustive-deps error
@@ -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<Maybe<string>>();
const [selectLabel, setSelected] = useState<Maybe<string>>();