diff --git a/.changeset/giant-meals-smile.md b/.changeset/giant-meals-smile.md new file mode 100644 index 0000000000..188bb77351 --- /dev/null +++ b/.changeset/giant-meals-smile.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-react': patch +--- + +Fix repetitive error reporting in EntityTypePicker diff --git a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx index 52b8ec8ff1..7b7845b8bc 100644 --- a/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx +++ b/plugins/catalog-react/src/components/EntityTypePicker/EntityTypePicker.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import React from 'react'; +import React, { useEffect } from 'react'; import { capitalize } from 'lodash'; import { Box } from '@material-ui/core'; import { useEntityTypeFilter } from '../../hooks/useEntityTypeFilter'; @@ -26,13 +26,16 @@ export const EntityTypePicker = () => { const alertApi = useApi(alertApiRef); const { error, types, selectedType, setType } = useEntityTypeFilter(); - if (!types) return null; + useEffect(() => { + if (error) { + alertApi.post({ + message: `Failed to load entity types`, + severity: 'error', + }); + } + }, [error, alertApi]); - if (error) { - alertApi.post({ - message: `Failed to load entity types`, - severity: 'error', - }); + if (!types || error) { return null; }