A checkbox click should not re-render the folder sidebar

Performancekamo-internal
Shipped
August 26, 2026 at 2:42 AM UTC
Author
kamo
Commit
a0b722b

Six call sites read the email store with a bare `useEmailStore()`. In zustand that subscribes to the WHOLE store, so any change anywhere in it re-renders the component — and selection state lives in the same store as labels, rules and smart folders. Ticking one checkbox in the message list updated selectedMessageIds and re-rendered the 1,207-line FolderSidebar, the label picker, the filter rule builder and the smart folder modal along with it, none of which read selection at all. Each site now selects the individual fields it uses. Actions are stable references in zustand, so selecting those never causes a render on its own; only a component that genuinely reads a changed value re-renders. MessageBrowser still re-renders on a selection change, which is correct — what it no longer does is re-render when labels, rules or smart folders move. Deliberately atomic selectors rather than one selector returning an object: zustand 5 dropped the automatic shallow comparison for object-returning selectors, so that form needs useShallow and reintroduces the same class of bug the moment someone forgets it. The rest of the codebase was already doing this correctly — 155 selector-based call sites against these 6. The four remaining bare subscriptions (esign, documents, hr, signature settings) pass the whole store object around internally and need restructuring rather than a selector, so they are left alone. Verified: tsc --noEmit clean over all five components and the store with their transitive imports; all 9 guards pass.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing