From 23afcf1db9c688716a198d5f26084ae467a2ae3d Mon Sep 17 00:00:00 2001 From: Kai Vandivier Date: Mon, 7 Oct 2024 23:59:18 +0200 Subject: [PATCH] fix: handle async parentAlertsAdd --- services/alerts/src/useAlert.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/alerts/src/useAlert.ts b/services/alerts/src/useAlert.ts index adc84e211..732d165ea 100644 --- a/services/alerts/src/useAlert.ts +++ b/services/alerts/src/useAlert.ts @@ -19,13 +19,18 @@ export const useAlert = ( typeof options === 'function' ? options(props) : options if (plugin && parentAlertsAdd && !showAlertsInPlugin) { - alertRef.current = parentAlertsAdd( + // Functions passed through post-robot are asynchronous + parentAlertsAdd( { message: resolvedMessage, options: resolvedOptions, }, alertRef - ) + // Conditional chaining gives backwards compatibility + // with cli-app-scripts < 11.7.2 + )?.then((newAlert: Alert) => { + alertRef.current = newAlert + }) } else { alertRef.current = add( {