From 41d94162d078022cdd67554c7b132d7a4481b97b Mon Sep 17 00:00:00 2001 From: foxxy Date: Wed, 2 Oct 2024 16:28:13 +0300 Subject: [PATCH] MSP-4164 add prevRoute to sessionStorage --- src/components/App.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/App.tsx b/src/components/App.tsx index 96bcc67..d025055 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,6 +1,7 @@ import { ConfigProvider } from 'antd' import ruRu from 'antd/locale/ru_RU' import { useEffect, useState } from 'react' +import { useLocation } from 'react-router-dom' import { darkTheme, lightTheme } from '@constants/theme.ts' @@ -18,6 +19,15 @@ const App = () => { : true ) + const location = useLocation() + + useEffect(() => { + const prevRoute = sessionStorage.getItem('prevRoute') + if (location.pathname !== prevRoute) { + sessionStorage.setItem('prevRoute', location.pathname) + } + }, [location]) + useEffect(() => { setTheme(() => (changeTheme ? darkTheme : lightTheme)) }, [changeTheme])