Make AlertDisplay not crash on undefined error message
Signed-off-by: Gustaf Räntilä <g.rantila@gmail.com>
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user