memoize initial theme

This commit is contained in:
Tom (plebeius.eth)
2024-08-26 12:31:15 +02:00
parent 1eb64ede3d
commit f95ff6049f
2 changed files with 3 additions and 6 deletions
-1
View File
@@ -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();
+3 -5
View File
@@ -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;