mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix theme warning
This commit is contained in:
+15
-6
@@ -1,4 +1,4 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom';
|
||||
import { isAllView, isSubscriptionsView } from './lib/utils/view-utils';
|
||||
import useIsMobile from './hooks/use-is-mobile';
|
||||
@@ -61,13 +61,22 @@ const BoardLayout = () => {
|
||||
};
|
||||
|
||||
const GlobalLayout = () => {
|
||||
const [theme] = useTheme();
|
||||
const [theme, setTheme] = useState('');
|
||||
const [currentTheme] = useTheme();
|
||||
|
||||
useEffect(() => {
|
||||
document.body.classList.add(theme);
|
||||
return () => {
|
||||
document.body.classList.remove(theme);
|
||||
};
|
||||
if (currentTheme !== theme) {
|
||||
setTheme(currentTheme);
|
||||
}
|
||||
}, [currentTheme, theme]);
|
||||
|
||||
useEffect(() => {
|
||||
if (theme) {
|
||||
document.body.classList.add(theme);
|
||||
return () => {
|
||||
document.body.classList.remove(theme);
|
||||
};
|
||||
}
|
||||
}, [theme]);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user