From 002836773db8f12f11ce05a3c1b70e3ec61c1461 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 14:15:37 +0000 Subject: [PATCH] Fix: React refresh preamble error The error "React refresh preamble was not loaded" in `sonner.tsx` suggests a problem with the Vite configuration or React refresh setup. The AI will investigate the Vite configuration (`vite.config.ts`) and the component's import/export structure to ensure proper React refresh functionality. --- src/App.tsx | 1 + src/components/ui/sonner.tsx | 9 +++++++-- src/components/ui/use-toast.ts | 5 +++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 92b44b2..3c9f7ac 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,3 +1,4 @@ + import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom'; import { Suspense, lazy, useEffect } from 'react'; import { Toaster } from "@/components/ui/sonner"; diff --git a/src/components/ui/sonner.tsx b/src/components/ui/sonner.tsx index 3541814..20fcc49 100644 --- a/src/components/ui/sonner.tsx +++ b/src/components/ui/sonner.tsx @@ -1,5 +1,8 @@ + +"use client" + import { useTheme } from "next-themes" -import { Toaster as Sonner, toast } from "sonner" +import { Toaster as Sonner } from "sonner" type ToasterProps = React.ComponentProps @@ -26,4 +29,6 @@ const Toaster = ({ ...props }: ToasterProps) => { ) } -export { Toaster, toast } +export { Toaster } +// Re-export toast function directly from sonner +export { toast } from "sonner" diff --git a/src/components/ui/use-toast.ts b/src/components/ui/use-toast.ts index d3da9e2..4bb01e6 100644 --- a/src/components/ui/use-toast.ts +++ b/src/components/ui/use-toast.ts @@ -1,4 +1,5 @@ -import { useToast, toast } from "@/hooks/use-toast"; +import { toast } from "@/components/ui/sonner" +import { useToast } from "@/hooks/use-toast" -export { useToast, toast }; +export { useToast, toast }