fix: Zustand selector anti-pattern causing infinite re-render + plugin loader path
- Fix usePluginStore(s => s.getAll*()) selectors that returned new arrays on every call, causing infinite re-render loops and permanent spinner - Affected: Sidebar, Settings, ContactDetail, ContactEditModal, PluginRouteRenderer - Use usePluginStore(s => s.manifests) + useMemo instead - Fix PluginRouteRenderer: show spinner instead of null when manifests loading - Fix PluginLoader: @/ path replacement ../ -> ../../ for correct dynamic imports
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { NavLink, Outlet } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { usePluginStore } from '@/store/pluginStore';
|
||||
@@ -6,7 +6,13 @@ import * as LucideIcons from 'lucide-react';
|
||||
|
||||
export function SettingsPage() {
|
||||
const { t } = useTranslation();
|
||||
const pluginSettingsPages = usePluginStore(s => s.getAllSettingsPages());
|
||||
const manifests = usePluginStore(s => s.manifests);
|
||||
const pluginSettingsPages = useMemo(
|
||||
() => manifests
|
||||
.flatMap((m) => m.settings_pages)
|
||||
.sort((a, b) => a.order - b.order),
|
||||
[manifests]
|
||||
);
|
||||
|
||||
const hardcodedNavItems = [
|
||||
{ to: '/settings/system', label: t('systemSettings.title'), icon: '\u2699\ufe0f' },
|
||||
|
||||
Reference in New Issue
Block a user