mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
memoize initial theme
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user