We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
something like this
toast.promise( myPromise, { loading: loadingProgress, // from useState hook for example success: 'Success', error: 'Error', }, )
The text was updated successfully, but these errors were encountered:
My solution is to use useRef.
This is implement example:
import { useRef } from "react"; const MyComponent = (props: any) => { const textRef = useRef<HTMLSpanElement>(null); const updateText = (text: string) => { if (textRef?.current) textRef.current.innerText = text; }; const onHandle = async () => { updateText("Initiating..."); await delay(3000); updateText("Optimizing images..."); await delay(3000); updateText("Saving..."); }; const onClick = () => { toast.promise(onHandle(), { loading: <span ref={textRef}>Saving...</span>, success: "Successfully!", error: (error) => { console.log(error); return "Something were wrong."; }, }); }; return ( <div> <button onClick={onClick}>Show me</button> </div> ); };
Sorry, something went wrong.
No branches or pull requests
something like this
The text was updated successfully, but these errors were encountered: