From 191c02f6ca1281ae0979ad99792b492efd7927ea Mon Sep 17 00:00:00 2001 From: Neil Marcellini Date: Tue, 22 Mar 2022 10:58:13 -0700 Subject: [PATCH] Retry growls when the ref is not available --- src/libs/Growl.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/Growl.js b/src/libs/Growl.js index b4915c22bad4..416b32be0e33 100644 --- a/src/libs/Growl.js +++ b/src/libs/Growl.js @@ -4,13 +4,17 @@ import CONST from '../CONST'; const growlRef = React.createRef(); /** - * Show the growl notification + * Show the growl notification. If the ref is not available, retry until it is. * * @param {String} bodyText * @param {String} type * @param {Number} [duration] */ function show(bodyText, type, duration = CONST.GROWL.DURATION) { + if (!growlRef.current) { + setTimeout(() => show(bodyText, type, duration), 100); + return; + } growlRef.current.show(bodyText, type, duration); }