-
-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
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
Can't find variable: Xt (next js 13) #524
Comments
Please provide a codesandbox demo with reproduction. |
I think it only happens with promise: <T>(promise: Promise<T>, options: PromiseToastOptions<T>) => {
const { success, loading, error } = options;
const toastId = toast.loading(loading);
return promise
.then((data) => toast.success(success(data), { id: toastId }))
.catch((e) => toast.error(error(e), { id: toastId }))
.finally(options.finally);
}, |
Nice. Can you provide a demo of the deployment that errors on vercel? |
@abdulrahimiliasu |
can you guide how to fix it? |
Here's the fix for Create a file import { toast } from "sonner";
type PromiseToastOptions<ToastData = any> = {
loading: string | React.ReactNode;
success: (data: ToastData) => React.ReactNode | string;
error: (e: Error) => React.ReactNode | string;
finally?: () => void | Promise<void>;
};
// Custom toast promise function
export const toast_custom_promise = (
promise: Promise<any>,
options: PromiseToastOptions<any>
) => {
const { success, loading, error, finally: finalCallback } = options;
const toastId = toast.loading(loading);
// Handle promise result: success or error
return promise
.then((data) => {
toast.success(success(data), { id: toastId });
})
.catch((e: Error) => {
toast.error(error(e), { id: toastId });
})
.finally(() => {
if (finalCallback) {
finalCallback();
}
});
}; |
This issue is with |
After deploying to
vercel
withnextjs 13
, thetoast.promise
returnsError:
Can't find variable: Xt
Reference Error
I've tried with all versions of node i.e
16
,18
,20
&22
, it still throws this error. It happens only after deploying to Vercel, works fine on local dev environment.The text was updated successfully, but these errors were encountered: