fix: stabilize store functions with selectors to prevent infinite loop
- Use usePluginToolbarStore((s) => s.registerItems) selector pattern - Remove store functions from useEffect dependency array - Store functions are stable references from zustand selectors
This commit is contained in:
@@ -282,7 +282,8 @@ export function MailPage() {
|
||||
}, []);
|
||||
|
||||
// Register toolbar items
|
||||
const { registerItems, unregisterPlugin } = usePluginToolbarStore();
|
||||
const registerItems = usePluginToolbarStore((s) => s.registerItems);
|
||||
const unregisterPlugin = usePluginToolbarStore((s) => s.unregisterPlugin);
|
||||
const selectedMailId = selectedMail?.id;
|
||||
const selectedMailFlagged = selectedMail?.is_flagged;
|
||||
useEffect(() => {
|
||||
@@ -370,7 +371,7 @@ export function MailPage() {
|
||||
},
|
||||
]);
|
||||
return () => unregisterPlugin('mail');
|
||||
}, [registerItems, unregisterPlugin, accounts, selectedAccountId, selectedMailId, selectedMailFlagged, handleAccountSwitch, handleSearch, handleCompose, handleReply, handleForward, handleToggleFlag, handleCreateEvent]);
|
||||
}, [accounts, selectedAccountId, selectedMailId, selectedMailFlagged, handleAccountSwitch, handleSearch, handleCompose, handleReply, handleForward, handleToggleFlag, handleCreateEvent]);
|
||||
|
||||
if (loadingAccounts) {
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user