wrap showToast in useMemo
This commit is contained in:
1 parent
1b97539eae
commit
7dbc7b3064
1 file changed
+3
@@ -1,6 +1,8 @@
|
||||
import { toast, type ToastOptions } from "react-toastify";
|
||||
import { useMemo } from "react";
|
||||
|
||||
export const useToast = () => {
|
||||
return useMemo(() => {
|
||||
const showToast = (message: string, options?: ToastOptions) => {
|
||||
toast.dismiss();
|
||||
const baseStyle: React.CSSProperties = {
|
||||
@@ -24,4 +26,5 @@ export const useToast = () => {
|
||||
showToast(msg, { ...opts, type: "warning" });
|
||||
|
||||
return { showToast, toastSuccess, toastError, toastInfo, toastWarning };
|
||||
}, []);
|
||||
};
|
||||
Reference in new issue
Block a user