Skip to content

fix: memoize Sparkline's derived rows/config (companion to #3, closes the rest of #2)#4

Open
DloomPlz wants to merge 1 commit into
Boring-Software-Inc:mainfrom
DloomPlz:fix/work-without-react-compiler
Open

fix: memoize Sparkline's derived rows/config (companion to #3, closes the rest of #2)#4
DloomPlz wants to merge 1 commit into
Boring-Software-Inc:mainfrom
DloomPlz:fix/work-without-react-compiler

Conversation

@DloomPlz

@DloomPlz DloomPlz commented Jul 12, 2026

Copy link
Copy Markdown

Heads-up

#3 already stabilizes the registerSeries/unregisterSeries + registerVariant/unregisterVariant callbacks (nice work @seanryy — I hadn't seen it before opening this, sorry for the noise). This PR is now trimmed down to only the piece #3 doesn't cover, so the two merge cleanly together and fully close #2.

Problem

Sparkline rebuilds its derived props every render:

// React Compiler memoizes these against `data` / `color`.
const rows = data.map((v) => ({ v }))
const config = { v: { color } }

Without the compiler, rows gets a fresh identity each pass — and rows feeds useRevision's adjust-state-during-render, which then never stabilizes: every render bumps the revision, resets the entrance gate, and re-renders. Same class of bug as #2/#3, different entry point (this one triggers even after #3 lands).

Fix

Memoize rows/config with useMemo against data/color — exactly what the compiler emits for compiler-enabled projects, so no behavior change there. Registry JSON regenerated with npm run build.

…t Compiler

Companion to Boring-Software-Inc#3 (which stabilizes the register/unregister callbacks):
Sparkline rebuilds rows/config on every render, and rows identity feeds
useRevision's adjust-state-during-render — which never stabilizes when
the array is fresh each pass. Memoize both against data/color.

Registry JSON regenerated via npm run build.
@DloomPlz DloomPlz changed the title fix: work without React Compiler (infinite effect loop on chart mount) fix: memoize Sparkline's derived rows/config (companion to #3, closes the rest of #2) Jul 12, 2026
@DloomPlz DloomPlz force-pushed the fix/work-without-react-compiler branch from 8a65d05 to 22435f7 Compare July 12, 2026 20:41
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.

Infinite "Maximum update depth exceeded" loop in all charts without React Compiler

1 participant