optimize excessive layout re-rendering due to react-router

This commit is contained in:
jeffvli
2025-11-25 01:40:11 -08:00
parent 0a6b9a1040
commit 359e442947
11 changed files with 166 additions and 161 deletions
@@ -14,7 +14,6 @@ import { TextInput } from '/@/shared/components/text-input/text-input';
export const ActionBar = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const { open } = useCommandPalette();
return (
@@ -50,15 +49,25 @@ export const ActionBar = () => {
<AppMenu />
</DropdownMenu.Dropdown>
</DropdownMenu>
<Button onClick={() => navigate(-1)} p="0.5rem">
<Icon icon="arrowLeftS" size="lg" />
</Button>
<Button onClick={() => navigate(1)} p="0.5rem">
<Icon icon="arrowRightS" size="lg" />
</Button>
<NavigateButtons />
</Group>
</Grid.Col>
</Grid>
</div>
);
};
const NavigateButtons = () => {
const navigate = useNavigate();
return (
<>
<Button onClick={() => navigate(-1)} p="0.5rem">
<Icon icon="arrowLeftS" size="lg" />
</Button>
<Button onClick={() => navigate(1)} p="0.5rem">
<Icon icon="arrowRightS" size="lg" />
</Button>
</>
);
};
@@ -19,10 +19,10 @@ export const SidebarItem = ({ children, className, to, ...props }: SidebarItemPr
<Button
className={clsx(
{
[styles.active]: isActive,
[styles.disabled]: props.disabled,
[styles.link]: true,
[styles.root]: true,
[styles.active]: isActive,
},
className,
)}
@@ -2,7 +2,6 @@ import clsx from 'clsx';
import { AnimatePresence, motion } from 'motion/react';
import { CSSProperties, MouseEvent, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router';
import styles from './sidebar.module.css';
@@ -39,7 +38,6 @@ import { Platform } from '/@/shared/types/types';
export const Sidebar = () => {
const { t } = useTranslation();
const location = useLocation();
const sidebar = useSidebarStore();
const { setSideBar } = useAppStoreActions();
const { sidebarPlaylistList } = useGeneralSettings();
@@ -60,6 +58,7 @@ export const Sidebar = () => {
}),
[t],
);
const upsizedImageUrl = currentSong?.imageUrl
?.replace(/size=\d+/, 'size=450')
.replace(/width=\d+/, 'width=450')