diff --git a/my-app/src/App.jsx b/my-app/src/App.jsx index 4998d44..7d0fe94 100644 --- a/my-app/src/App.jsx +++ b/my-app/src/App.jsx @@ -1,5 +1,6 @@ import { BrowserRouter, Routes, Route } from "react-router-dom"; import { useState, useEffect } from "react"; +import { motion } from "framer-motion"; import Home from "./pages/Home"; import About from "./pages/About"; import NotFound from "./pages/404"; @@ -10,37 +11,44 @@ import Base from "./layouts/Base"; import Subscribe from "./components/Subscribe"; import Loader from "./components/Loader"; -export default function App() { - const [isVisible, setIsVisible] = useState(false); +// Custom hook to handle the loader +const useLoader = (duration = 1500) => { const [loading, setLoading] = useState(true); - useEffect(() => { - const timer = setTimeout(() => { - setLoading(false); - }, 1500); // Adjusted loader time to 1.5 seconds for smoother transition + const timer = setTimeout(() => setLoading(false), duration); + return () => clearTimeout(timer); // This is the cleanup timer + }, [duration]); + return loading; +}; - return () => clearTimeout(timer); // Cleaning up timer - }, []); - - const handleSetVisible = (value) => setIsVisible(value); +export default function App() { + const [isVisible, setVisible] = useState(false); + const loading = useLoader(); // Loader logic return (