Chore: Migrate containers: Toast to Typescript (#3913)

This commit is contained in:
Reinaldo Neto 2022-03-18 11:25:03 -03:00 committed by GitHub
parent 75f3f90913
commit fae46f565b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 5 deletions

View File

@ -26,9 +26,9 @@ interface IToastProps {
}
class Toast extends React.Component<IToastProps, any> {
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<IToastProps, any> {
}
componentWillUnmount() {
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);
}