An opinionated toast component for React.
Get history of Toast (#266)
Dharanish Vd4c5ee77e190
diff --git a/src/state.ts b/src/state.tsindex 03f7915..601f92f 100644--- a/src/state.ts+++ b/src/state.ts@@ -1,5 +1,6 @@+import type { ExternalToast, PromiseData, PromiseT, ToastT, ToastToDismiss, ToastTypes } from './types';+import React from 'react';-import type { ExternalToast, ToastT, PromiseData, PromiseT, ToastToDismiss, ToastTypes } from './types';let toastsCounter = 1;@@ -189,15 +190,21 @@ const toastFunction = (message: string | React.ReactNode, data?: ExternalToast)const basicToast = toastFunction;+const getHistory = () => ToastState.toasts;+// We use `Object.assign` to maintain the correct types as we would lose them otherwise-export const toast = Object.assign(basicToast, {- success: ToastState.success,- info: ToastState.info,- warning: ToastState.warning,- error: ToastState.error,- custom: ToastState.custom,- message: ToastState.message,- promise: ToastState.promise,- dismiss: ToastState.dismiss,- loading: ToastState.loading,-});+export const toast = Object.assign(+ basicToast,+ {+ success: ToastState.success,+ info: ToastState.info,+ warning: ToastState.warning,+ error: ToastState.error,+ custom: ToastState.custom,+ message: ToastState.message,+ promise: ToastState.promise,+ dismiss: ToastState.dismiss,+ loading: ToastState.loading,+ },+ { getHistory },+);