From 677b28818deb8d77579030cb3c380c81a40bfab5 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Mon, 17 Feb 2020 13:06:08 -0300 Subject: [PATCH] [FIX] Prevent toast ref error (#1744) --- app/containers/Toast.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/containers/Toast.js b/app/containers/Toast.js index cc1c3e5c..832aae70 100644 --- a/app/containers/Toast.js +++ b/app/containers/Toast.js @@ -43,15 +43,19 @@ class Toast extends React.Component { EventEmitter.removeListener(LISTENER); } + getToastRef = toast => this.toast = toast; + showToast = ({ message }) => { - this.toast.show(message, 1000); + if (this.toast && this.toast.show) { + this.toast.show(message, 1000); + } } render() { const { theme } = this.props; return ( this.toast = toast} + ref={this.getToastRef} position='center' style={[styles.toast, { backgroundColor: themes[theme].toastBackground }]} textStyle={[styles.text, { color: themes[theme].buttonText }]}