From 48dd501d17acfcda69915582e938bf6f804b0328 Mon Sep 17 00:00:00 2001 From: rgrgogu Date: Sat, 25 Jul 2026 10:22:52 +0800 Subject: [PATCH] fix bugs --- src/modules/client/pages/CourseCheckout.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/client/pages/CourseCheckout.jsx b/src/modules/client/pages/CourseCheckout.jsx index 1bc6e64..16e908e 100644 --- a/src/modules/client/pages/CourseCheckout.jsx +++ b/src/modules/client/pages/CourseCheckout.jsx @@ -75,7 +75,14 @@ export default function CourseCheckout() { if (!wasCancelled) return; const orderId = searchParams.get("token"); if (orderId) cancelCourseOrder(orderId); - toast("Payment was cancelled."); + // Deferred to a new macrotask: this page renders as an child, + // which sits before in ClientLayout's JSX — so a toast fired + // synchronously in this mount-time effect races the Toaster's own mount + // effect (which subscribes to sonner's store) and is silently dropped, + // since sonner only notifies subscribers already listening at publish + // time (no replay for late subscribers). setTimeout(0) pushes the call + // past the current effect-flush, after Toaster has subscribed. + setTimeout(() => toast("Payment was cancelled."), 0); navigate(`/course/${courseId}/checkout`, { replace: true }); }, [wasCancelled]); // eslint-disable-line react-hooks/exhaustive-deps