mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
perf(react-doctor): fix compiler-blocking patterns, raise score 72→81
Replace sync setState-in-effect with keyed remount and render-derived patterns in app, error-display, topbar-edit-modal, catalog-filters; use useCurrentTime() instead of Date.now() in hot paths; fix conditional hooks, passive scroll listeners, lodash path imports.
This commit is contained in:
+5
-12
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import { Navigate, Outlet, Route, Routes, useLocation, useParams } from 'react-router-dom';
|
||||
import { useAccount, useAccountComment, useSubplebbit } from '@plebbit/plebbit-react-hooks';
|
||||
import useAccountsStore from '@plebbit/plebbit-react-hooks/dist/stores/accounts';
|
||||
@@ -108,23 +108,16 @@ const BoardLayout = () => {
|
||||
};
|
||||
|
||||
const GlobalLayout = () => {
|
||||
const [theme, setTheme] = useState('');
|
||||
const [currentTheme] = useTheme();
|
||||
|
||||
useEffect(() => {
|
||||
if (currentTheme !== theme) {
|
||||
setTheme(currentTheme);
|
||||
}
|
||||
}, [currentTheme, theme]);
|
||||
|
||||
useEffect(() => {
|
||||
if (theme) {
|
||||
document.body.classList.add(theme);
|
||||
if (currentTheme) {
|
||||
document.body.classList.add(currentTheme);
|
||||
return () => {
|
||||
document.body.classList.remove(theme);
|
||||
document.body.classList.remove(currentTheme);
|
||||
};
|
||||
}
|
||||
}, [theme]);
|
||||
}, [currentTheme]);
|
||||
|
||||
const { activeCid, parentNumber, threadNumber, threadCid, subplebbitAddress, closeModal, showReplyModal, scrollY } = useReplyModalStore();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user