The intended purpose of the transition is to show it on the screen as the route loads in…
- User
The intended purpose of the transition is to show it on the screen as the route loads in the background(a form of delay to ensure all components on the route finish loading) whenever a route change occurs on the website. Currently the transition does not show at all: App.js: import React, { useEffect, useState} from "react"; import { BrowserRouter, Routes, Route, useLocation} from 'react-router-dom' import Home from "./Home"; import Products from "./Products"; import Cart from "./Cart"; import SingleProduct from './SingleProduct' import Error from "./Error"; import { GlobalStyle } from "./GlobalStyle"; import { ThemeProvider } from "styled-components"; import Header from "./components/Header"; import Footer from "./components/Footer"; import GoToTop from "./components/GoToTop"; import Transition from "./components/Transition"; import { extendTheme, ChakraProvider } from '@chakra-ui/react';
// Inside App.js, right above the App component definition
const RouteTransitionManager = () => { const location = useLocation(); // Now correctly used within the context of const [isTransitioning, setIsTransitioning] = useState(false);
useEffect(() => { setIsTransitioning(true); const timer = setTimeout(() => setIsTransitioning(false), 800); // Match with your transition duration return () => clearTimeout(timer); }, [location]);
return isTransitioning ? : null; };
const App = () => { const theme = { colors: { heading: "rgb(24 24 29)", text: "rgba(29 ,29, 29, .8)", white: "#fff", black: " #212529", helper: "#8490ff",
codebg: "#dee5f3", footer_bg: "#0a1435", btn: "rgb(98 84 243)", border: "rgba(98, 84, 243, 0.5)", hr: "#ffffff", gradient: "linear-gradient(0deg, rgb(132 144 255) 0%, rgb(98 189 252) 100%)", shadow: "rgba(0, 0, 0, 0.02) 0px 1px 3px 0px,rgba(27, 31, 35, 0.15) 0px 0px 0px 1px;", shadowSupport: " rgba(0, 0, 0, 0.16) 0px 1px 4px", }, media: { mobile: "768px", tab: "998px", },}; const themeToast = extendTheme({ components: { Toast: { baseStyle: { // Specify your custom styles here fontSize: "17px !important", }, }, }, });
return ( <Route path="/" element={} /> <Route path="/products" element={} /> <Route path="/singleproduct/:id" element={} /> <Route path="/cart" element={} /> <Route path="*" element={} /> ); };
export default App; Transition.jsx: import { motion } from "framer-motion"; import React from "react";
const Transition = () => {
code - Assistant