Make AlertDisplay not crash on undefined error message

Signed-off-by: Gustaf Räntilä <g.rantila@gmail.com>
This commit is contained in:
Gustaf Räntilä
2022-11-30 11:24:09 +01:00
parent a977c6dfe5
commit d2e3bf6737
2 changed files with 7 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-components': patch
---
Made AlertDisplay not crash on undefined error messages
@@ -42,7 +42,7 @@ export type AlertDisplayProps = {
/** @public */
export function AlertDisplay(props: AlertDisplayProps) {
const [messages, setMessages] = useState<Array<AlertMessage>>([]);
const [messages, setMessages] = useState<Array<Partial<AlertMessage>>>([]);
const alertApi = useApi(alertApiRef);
const { anchorOrigin = { vertical: 'top', horizontal: 'center' } } = props;
@@ -83,7 +83,7 @@ export function AlertDisplay(props: AlertDisplayProps) {
severity={firstMessage.severity}
>
<span>
{firstMessage.message.toString()}
{`${firstMessage?.message}`}
{messages.length > 1 && (
<em>{` (${messages.length - 1} older ${pluralize(
'message',