catalog-graph: fix flickering when parent re-renders

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2025-01-29 10:15:30 +01:00
parent b07756e455
commit 719e48dbb4
3 changed files with 9 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-graph': patch
---
Fixed an issue causing the `CatalogGraphCard` to redraw its content whenever the parent component re-renders, resulting in flickering.
@@ -28,7 +28,7 @@ import {
} from '@backstage/plugin-catalog-react';
import { makeStyles, Theme } from '@material-ui/core/styles';
import qs from 'qs';
import React, { MouseEvent, ReactNode, useCallback } from 'react';
import React, { MouseEvent, ReactNode, useCallback, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';
import { catalogGraphRouteRef } from '../../routes';
import {
@@ -86,7 +86,7 @@ export const CatalogGraphCard = (
} = props;
const { entity } = useEntity();
const entityName = getCompoundEntityRef(entity);
const entityName = useMemo(() => getCompoundEntityRef(entity), [entity]);
const catalogEntityRoute = useRouteRef(entityRouteRef);
const catalogGraphRoute = useRouteRef(catalogGraphRouteRef);
const navigate = useNavigate();
+2
View File
@@ -685,7 +685,9 @@ export function humanizeEntityRef(
export function InspectEntityDialog(props: {
open: boolean;
entity: Entity;
initialTab?: 'overview' | 'ancestry' | 'colocated' | 'json' | 'yaml';
onClose: () => void;
onSelect?: (tab: string) => void;
}): React_2.JSX.Element | null;
// @public