diff --git a/src/app.tsx b/src/app.tsx index dd8a07f4..f305c045 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -18,7 +18,6 @@ import SubplebbitStats from './components/subplebbit-stats'; import TopBar from './components/topbar'; import { timeFilterNames } from './hooks/use-time-filter'; import useTheme from './hooks/use-theme'; -import useInitialTheme from './hooks/use-initial-theme'; const BoardLayout = () => { const { accountCommentIndex, subplebbitAddress, timeFilterName } = useParams(); diff --git a/src/hooks/use-initial-theme.ts b/src/hooks/use-initial-theme.ts index af0978d9..0af95177 100644 --- a/src/hooks/use-initial-theme.ts +++ b/src/hooks/use-initial-theme.ts @@ -1,4 +1,4 @@ -import { useEffect } from 'react'; +import { useMemo } from 'react'; import { useLocation, useParams } from 'react-router-dom'; import useThemeStore from '../stores/use-theme-store'; import useDefaultSubplebbits from './use-default-subplebbits'; @@ -18,9 +18,7 @@ const useInitialTheme = () => { const isInSubscriptionsView = isSubscriptionsView(location.pathname, params); const isInPendingPostView = isPendingPostView(location.pathname, params); - let initialTheme = 'yotsuba'; - - useEffect(() => { + const initialTheme = useMemo(() => { let theme = 'yotsuba'; if (isInPendingPostView) { @@ -38,7 +36,7 @@ const useInitialTheme = () => { } } - initialTheme = theme; + return theme; }, [isInPendingPostView, isInAllView, isInSubscriptionsView, isInHomeView, isInNotFoundView, subplebbitAddress, getTheme, currentTheme, subplebbits]); return initialTheme;