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])