(props: ToastProps | null)
| 136 | const [visible, setVisible] = useState<boolean>(false); |
| 137 | |
| 138 | const setToast = (props: ToastProps | null) => { |
| 139 | if (props === null) { |
| 140 | setVisible(false); |
| 141 | // setTimeout used for smooth transition |
| 142 | const timeout = setTimeout(() => { |
| 143 | setToastProps(props); |
| 144 | }, 500); |
| 145 | |
| 146 | setToastTimeout(timeout); |
| 147 | } else { |
| 148 | clearTimeout(toastTimeout); |
| 149 | setToastProps({ id: Date.now().toString(), ...props }); |
| 150 | setVisible(true); |
| 151 | } |
| 152 | }; |
| 153 | |
| 154 | const handleClose = () => { |
| 155 | setToast(null); |