Skip to content

Commit

Permalink
Fix auto-remove not working in toast.dismiss()
Browse files Browse the repository at this point in the history
  • Loading branch information
yj-ang authored and timolins committed Jan 6, 2021
1 parent 1974f5c commit d58446b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ toast.error = createHandler('error');
toast.success = createHandler('success');
toast.loading = createHandler('loading');

toast.dismiss = (toastId?: string) =>
toast.dismiss = (toastId?: string) => {
dispatch({ type: ActionType.DISMISS_TOAST, toastId });
setTimeout(() => {
dispatch({
type: ActionType.REMOVE_TOAST,
toastId,
});
}, 1000);
};

toast.remove = (toastId?: string) =>
dispatch({ type: ActionType.REMOVE_TOAST, toastId });

Expand Down

0 comments on commit d58446b

Please sign in to comment.