Please make Vanilla JS version #254
sudhamjayanthi
started this conversation in
Ideas
Replies: 1 comment
-
There is apparently vanilla-hot-toast built on top of react-hot-toast and bundled with Preact. The repo is private so I don't know if you should use it in production! It's basically just this: import { render, h } from "preact";
import { toast, Toaster, ToasterProps } from "react-hot-toast";
type ExtendedToast = typeof toast & {
setConfig: (config: Partial<ToasterProps>) => void;
};
declare global {
interface Window {
toast: ExtendedToast;
}
}
let root: HTMLElement | null = null;
const startToaster = (config?: ToasterProps) => {
if (!root) {
root = document.createElement("div");
root.id = "hot-toast";
document.body.appendChild(root);
}
window.toast = toast as ExtendedToast;
window.toast.setConfig = (config: Partial<ToasterProps>) => {
startToaster(config);
};
window.toast.setConfig({
toastOptions: {
duration: 10000,
},
});
render(<Toaster {...config} />, root);
};
startToaster();
export { toast, startToaster }; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I love this library so much and would love to have a simple vanilla js implementation of this to use in my non-react projects! Thanks!
Beta Was this translation helpful? Give feedback.
All reactions