fix: resolve stale closures in CandleChart click handler
Convert drawingState, selectedLineId, dragState, and annotations to refs that stay in sync with state via useEffect. The chart click handler (subscribeClick) captured stale closure values for these variables. Now reads from refs (e.g. drawingStateRef.current) so the handler always sees the latest state, and removed the stale state variables from the useEffect dependency array. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
45a23047dd
commit
73c88f8211
2 changed files with 35 additions and 22 deletions
|
|
@ -65,7 +65,7 @@
|
|||
|
||||
- [x] 7.1 `[opus]` Fix stale closure in `fetchPredictions`: extract `modelInfo` into a `useRef` that stays in sync with state, use ref in `generateCacheKey` (`src/app/page.tsx:489-552`)
|
||||
- [x] 7.2 `[opus]` Add AbortController to `fetchPredictions` and `handleFetchBatchPredictions`: store controller in ref, abort previous on new request, discard stale responses (`src/app/page.tsx:494-663`)
|
||||
- [ ] 7.3 `[opus]` Fix stale closure in CandleChart click handler: convert `drawingState`, `selectedLineId`, `dragState`, `annotations` to refs, update refs alongside setState, read refs in handler (`src/components/CandleChart.tsx:572-971`)
|
||||
- [x] 7.3 `[opus]` Fix stale closure in CandleChart click handler: convert `drawingState`, `selectedLineId`, `dragState`, `annotations` to refs, update refs alongside setState, read refs in handler (`src/components/CandleChart.tsx:572-971`)
|
||||
- [ ] 7.4 `[opus]` Fix stale closure in SpanAnnotationManager keyboard handler: wrap `handleDeleteSpan` in `useCallback`, use ref for `selectedSpanId` (`src/components/SpanAnnotationManager.tsx:461-535`)
|
||||
|
||||
## 8. Frontend — Memory Leaks & Performance
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue