Chore: Migrate containers: Toast to Typescript (#3913)
This commit is contained in:
parent
75f3f90913
commit
fae46f565b
|
@ -26,9 +26,9 @@ interface IToastProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Toast extends React.Component<IToastProps, any> {
|
class Toast extends React.Component<IToastProps, any> {
|
||||||
private listener: any;
|
private listener?: Function;
|
||||||
|
|
||||||
private toast: any;
|
private toast: EasyToast | null | undefined;
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.listener = EventEmitter.addEventListener(LISTENER, this.showToast);
|
this.listener = EventEmitter.addEventListener(LISTENER, this.showToast);
|
||||||
|
@ -43,12 +43,14 @@ class Toast extends React.Component<IToastProps, any> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
if (this.listener) {
|
||||||
EventEmitter.removeListener(LISTENER, 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) {
|
if (this.toast && this.toast.show) {
|
||||||
this.toast.show(message, 1000);
|
this.toast.show(message, 1000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue