Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/components/NameManagerDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ import { useFocusTrap } from '@/hooks/useFocusTrap'
import { selectionToAbsRange } from '@/lib/namedRanges'
import type { NamedRange } from '@/types'

// Stable empty-array reference so the selector below doesn't return a fresh
// `[]` each render (which would fail Zustand's Object.is check and loop
// forever — React error #185).
const EMPTY_NAMED_RANGES: NamedRange[] = []

export function NameManagerDialog() {
const show = useStore((s) => s.showNameManagerDialog)
const setShow = useStore((s) => s.setShowNameManagerDialog)
const namedRanges = useStore((s) => s.workbook.namedRanges ?? [])
const namedRanges = useStore((s) => s.workbook.namedRanges ?? EMPTY_NAMED_RANGES)
const sheets = useStore((s) => s.workbook.sheets)
const selection = useStore((s) => s.selection)
const activeSheetId = useStore((s) => s.activeSheetId)
Expand Down
5 changes: 5 additions & 0 deletions src/store/slices/chatSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ export function createChatActions(
if (msg) msg.pinned = !msg.pinned
}),

// Allocates a fresh array each call. NEVER call this inside a Zustand
// selector body (e.g. useStore((s) => s.getPinnedMessages())) — the new
// reference fails Object.is every render and causes an infinite re-render
// loop (React error #185). Select the function reference and call it in
// an effect/handler, or wrap the result with useShallow.
getPinnedMessages: () => get().messages.filter((m) => m.pinned),

sendMessage: () => {
Expand Down
Loading