From 5f7d1e303d46c5f03657188e1b678e9e8cbd394a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 16 Mar 2022 15:52:02 +0100 Subject: [PATCH] badges: use useAsyncEntity Signed-off-by: Patrik Oldsberg --- .changeset/quiet-dots-raise.md | 5 +++++ plugins/badges/src/components/EntityBadgesDialog.tsx | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/quiet-dots-raise.md diff --git a/.changeset/quiet-dots-raise.md b/.changeset/quiet-dots-raise.md new file mode 100644 index 0000000000..237cf47c81 --- /dev/null +++ b/.changeset/quiet-dots-raise.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-badges': patch +--- + +Fixed an error caused by the `EntityBadgesDialog` trying to access the entity before it is loaded. diff --git a/plugins/badges/src/components/EntityBadgesDialog.tsx b/plugins/badges/src/components/EntityBadgesDialog.tsx index 1ae5f69326..422dbc96a3 100644 --- a/plugins/badges/src/components/EntityBadgesDialog.tsx +++ b/plugins/badges/src/components/EntityBadgesDialog.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { useEntity } from '@backstage/plugin-catalog-react'; +import { useAsyncEntity } from '@backstage/plugin-catalog-react'; import { Box, Button, @@ -44,7 +44,7 @@ type Props = { export const EntityBadgesDialog = ({ open, onClose }: Props) => { const theme = useTheme(); - const { entity } = useEntity(); + const { entity } = useAsyncEntity(); const fullScreen = useMediaQuery(theme.breakpoints.down('sm')); const badgesApi = useApi(badgesApiRef);