Merge pull request #32082 from OSfrog/fix/catalog-about-card-filter-before-useprops
fix(catalog): filter icon links before calling useProps
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog': patch
|
||||
---
|
||||
|
||||
Fixed `catalogAboutEntityCard` to filter icon links before calling useProps(), preventing side effects from hooks in filtered-out links
|
||||
@@ -41,12 +41,14 @@ export const catalogAboutEntityCard = EntityCardBlueprint.makeWithOverrides({
|
||||
// The "useProps" functions may be calling other hooks, so we need to
|
||||
// call them in a component function to avoid breaking the rules of hooks.
|
||||
const links = inputs.iconLinks.reduce((rest, iconLink) => {
|
||||
const props = iconLink.get(EntityIconLinkBlueprint.dataRefs.useProps)();
|
||||
const filter = buildFilterFn(
|
||||
iconLink.get(EntityIconLinkBlueprint.dataRefs.filterFunction),
|
||||
iconLink.get(EntityIconLinkBlueprint.dataRefs.filterExpression),
|
||||
);
|
||||
if (filter(entity)) {
|
||||
const props = iconLink.get(
|
||||
EntityIconLinkBlueprint.dataRefs.useProps,
|
||||
)();
|
||||
return [...rest, props];
|
||||
}
|
||||
return rest;
|
||||
|
||||
Reference in New Issue
Block a user