[FIX] Prevent toast ref error (#1744)
This commit is contained in:
parent
290c53efa9
commit
677b28818d
|
@ -43,15 +43,19 @@ class Toast extends React.Component {
|
||||||
EventEmitter.removeListener(LISTENER);
|
EventEmitter.removeListener(LISTENER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getToastRef = toast => this.toast = toast;
|
||||||
|
|
||||||
showToast = ({ message }) => {
|
showToast = ({ message }) => {
|
||||||
this.toast.show(message, 1000);
|
if (this.toast && this.toast.show) {
|
||||||
|
this.toast.show(message, 1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { theme } = this.props;
|
const { theme } = this.props;
|
||||||
return (
|
return (
|
||||||
<EasyToast
|
<EasyToast
|
||||||
ref={toast => this.toast = toast}
|
ref={this.getToastRef}
|
||||||
position='center'
|
position='center'
|
||||||
style={[styles.toast, { backgroundColor: themes[theme].toastBackground }]}
|
style={[styles.toast, { backgroundColor: themes[theme].toastBackground }]}
|
||||||
textStyle={[styles.text, { color: themes[theme].buttonText }]}
|
textStyle={[styles.text, { color: themes[theme].buttonText }]}
|
||||||
|
|
Loading…
Reference in New Issue