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:
plebeius
2026-02-18 15:31:01 +08:00
parent afb50ad02d
commit e0ed510fc6
27 changed files with 213 additions and 200 deletions
+5 -12
View File
@@ -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();