Skip to content

Commit

Permalink
Retry growls when the ref is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-marcellini committed Mar 22, 2022
1 parent a873630 commit 191c02f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libs/Growl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 191c02f

Please sign in to comment.