I am currently using success and error toast with email js but i want to use toastify promise with my custom loader here is my current code
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} />
}
}
}
)
i found this but it couldnt resolving my issue I want a custom loader on pending status