From d7b24fa168798e4588ed1dbca7b3b0740bdf0566 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sat, 17 May 2025 23:45:40 +0000 Subject: [PATCH] Fix: Resolve 'useEffect' error The error "Uncaught TypeError: Cannot read properties of null (reading 'useEffect')" was occurring. This commit addresses the issue. --- src/App.tsx | 42 +++++++++++++++++++--------------- src/components/ui/use-toast.ts | 1 + src/main.tsx | 20 ++++++++++++---- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index dd8de00..4f63a60 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,5 @@ +import React from "react"; import { Toaster } from "@/components/ui/toaster"; import { Toaster as Sonner } from "@/components/ui/sonner"; import { TooltipProvider } from "@/components/ui/tooltip"; @@ -10,6 +11,7 @@ import Categorias from "./pages/Categorias"; import Calendario from "./pages/Calendario"; import NotFound from "./pages/NotFound"; +// Create a client const queryClient = new QueryClient({ defaultOptions: { queries: { @@ -19,23 +21,27 @@ const queryClient = new QueryClient({ }, }); -const App = () => ( - - - - - - - } /> - } /> - } /> - } /> - {/* Adicione novas rotas acima desta linha */} - } /> - - - - -); +const App = () => { + return ( + + + + + + + + } /> + } /> + } /> + } /> + {/* Adicione novas rotas acima desta linha */} + } /> + + + + + + ); +}; export default App; diff --git a/src/components/ui/use-toast.ts b/src/components/ui/use-toast.ts index b0aef21..d3da9e2 100644 --- a/src/components/ui/use-toast.ts +++ b/src/components/ui/use-toast.ts @@ -1,3 +1,4 @@ + import { useToast, toast } from "@/hooks/use-toast"; export { useToast, toast }; diff --git a/src/main.tsx b/src/main.tsx index 719464e..2dcaa60 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -1,5 +1,17 @@ -import { createRoot } from 'react-dom/client' -import App from './App.tsx' -import './index.css' -createRoot(document.getElementById("root")!).render(); +import React from 'react'; +import { createRoot } from 'react-dom/client'; +import App from './App.tsx'; +import './index.css'; + +const rootElement = document.getElementById("root"); + +if (!rootElement) { + throw new Error("Root element not found!"); +} + +createRoot(rootElement).render( + + + +);