From fae46f565b4d2cb3a887ac305dcdee40757f0408 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Fri, 18 Mar 2022 11:25:03 -0300 Subject: [PATCH] Chore: Migrate containers: Toast to Typescript (#3913) --- app/containers/Toast.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/containers/Toast.tsx b/app/containers/Toast.tsx index 7dca3e14..ba1598f9 100644 --- a/app/containers/Toast.tsx +++ b/app/containers/Toast.tsx @@ -26,9 +26,9 @@ interface IToastProps { } class Toast extends React.Component { - private listener: any; + private listener?: Function; - private toast: any; + private toast: EasyToast | null | undefined; componentDidMount() { this.listener = EventEmitter.addEventListener(LISTENER, this.showToast); @@ -43,12 +43,14 @@ class Toast extends React.Component { } componentWillUnmount() { - EventEmitter.removeListener(LISTENER, this.listener); + if (this.listener) { + EventEmitter.removeListener(LISTENER, this.listener); + } } - getToastRef = (toast: any) => (this.toast = toast); + getToastRef = (toast: EasyToast | null) => (this.toast = toast); - showToast = ({ message }: any) => { + showToast = ({ message }: { message: string }) => { if (this.toast && this.toast.show) { this.toast.show(message, 1000); }