mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
fix bugs
This commit is contained in:
@@ -75,7 +75,14 @@ export default function CourseCheckout() {
|
|||||||
if (!wasCancelled) return;
|
if (!wasCancelled) return;
|
||||||
const orderId = searchParams.get("token");
|
const orderId = searchParams.get("token");
|
||||||
if (orderId) cancelCourseOrder(orderId);
|
if (orderId) cancelCourseOrder(orderId);
|
||||||
toast("Payment was cancelled.");
|
// Deferred to a new macrotask: this page renders as an <Outlet /> child,
|
||||||
|
// which sits before <Toaster /> 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 });
|
navigate(`/course/${courseId}/checkout`, { replace: true });
|
||||||
}, [wasCancelled]); // eslint-disable-line react-hooks/exhaustive-deps
|
}, [wasCancelled]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user