Skip to content

An opinionated toast component for React.

Returning the id for a custom toast (#202)

Davydov Artyomeb3a209a3530
diff --git a/src/state.ts b/src/state.ts
index dde5a5a..b917f56 100644
--- a/src/state.ts
+++ b/src/state.ts
@@ -153,6 +153,7 @@ class Observer {
custom = (jsx: (id: number | string) => React.ReactElement, data?: ExternalToast) => {
const id = data?.id || toastsCounter++;
this.publish({ jsx: jsx(id), id, ...data });
+ return id;
};
}
@@ -183,4 +184,4 @@ export const toast = Object.assign(basicToast, {
promise: ToastState.promise,
dismiss: ToastState.dismiss,
loading: ToastState.loading,
-});
\ No newline at end of file
+});