我目前正在对邮箱js使用成功和错误祝wine 词 但是我想通过我的定制加载器使用toastify Promise,这是我当前的代码
import emailjs from "@emailjs/browser";
import { toast } from 'react-toastify';
export const sendEmail = ({ service_id, templete_id, values, theme, setIsloading, pubkey }) => {
emailjs.send(service_id, templete_id, values, pubkey).then(
() => {
toast.success("Application submitted !", {theme})
setIsloading(false);
},
(error) => {
console.error(error);
toast.error("Something went wrong.", {theme});
setIsloading(false);
}
);
};
const resolveWithSomeData = new Promise(resolve => setTimeout(() => resolve("world"), 3000));
toast.promise(
resolveWithSomeData,
{
pending: {
render(){
return "I'm loading"
},
icon: false,
},
success: {
render({data}){
return `Hello ${data}`
},
// other options
icon: "?",
},
error: {
render({data}){
// When the promise reject, data will contains the error
return <MyErrorComponent message={data.message} />
}
}
}
)
我找到了这个,但它不能解决我的问题,我想要一个挂起状态的自定义加载器