Fix repetitive error reporting in EntityTypePicker

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-06-30 14:37:43 +02:00
parent 0654c202e6
commit 35a3e4e4cf
2 changed files with 15 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-react': patch
---
Fix repetitive error reporting in EntityTypePicker
@@ -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;
}