Skip to content

Fix infinite render loop crash in EvidencePanel - #10

Open
KshitijKoranne wants to merge 1 commit into
MeyerThorsten:mainfrom
KshitijKoranne:patch-1
Open

Fix infinite render loop crash in EvidencePanel#10
KshitijKoranne wants to merge 1 commit into
MeyerThorsten:mainfrom
KshitijKoranne:patch-1

Conversation

@KshitijKoranne

Copy link
Copy Markdown

The selector useEvidenceStore((s) => s.attachments.filter(...)) returns a new array on every render. With useSyncExternalStore (Zustand v5), this makes getSnapshot return a different reference each time, triggering "Maximum update depth exceeded" and crashing EvidencePanel on mount (blank screen on app load).

Fix: select the stable attachments array from the store and derive the filtered list in a useMemo keyed on [attachments, entityId]. Same result, stable reference, no loop.

The selector `useEvidenceStore((s) => s.attachments.filter(...))` returns a new array on every render. With useSyncExternalStore (Zustand v5), this makes getSnapshot return a different reference each time, triggering "Maximum update depth exceeded" and crashing EvidencePanel on mount (blank screen on app load).

Fix: select the stable `attachments` array from the store and derive the filtered list in a useMemo keyed on [attachments, entityId]. Same result, stable reference, no loop.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant