Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes infinite rendering loops by refactoring tooltip and offset calculations to better leverage memoization. The changes extract axis data key selection into a memoized selector and optimize chart offset calculations by breaking down complex computations into smaller, memoizable functions.
- Replaces direct axis object usage with memoized data key selection in tooltip payload logic
- Refactors chart offset calculations to use separate functions for each axis direction
- Updates test assertions to reflect the reduced render counts achieved through better memoization
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/state/selectors/selectTooltipAxis.ts | Adds new memoized selector for tooltip axis data key |
| src/state/selectors/tooltipSelectors.ts | Updates to use the new data key selector instead of full axis object |
| src/state/selectors/selectors.ts | Updates tooltip payload selector to use data key selector |
| src/state/selectors/combiners/combineTooltipPayload.ts | Changes parameter from axis object to data key for better memoization |
| src/state/selectors/selectChartOffsetInternal.ts | Refactors offset calculation into separate functions for each axis direction |
| test/state/selectors/selectors.spec.tsx | Updates tests to pass data key directly instead of axis object |
| test/hooks/useOffset.spec.tsx | Adds test for infinite rendering fix and updates render count assertions |
| test/context/chartLayoutContext.spec.tsx | Updates render count assertion to reflect memoization improvements |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6247 +/- ##
=======================================
Coverage 96.63% 96.64%
=======================================
Files 221 221
Lines 19898 19931 +33
Branches 4093 4107 +14
=======================================
+ Hits 19229 19262 +33
Misses 663 663
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 1.85kB (0.08%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-umdAssets Changed:
view changes for bundle: recharts/bundle-cjsAssets Changed:
view changes for bundle: recharts/bundle-es6Assets Changed:
|
|
What a precarious thing |
Description
Shuffle code around to better leverage memoization.
Related Issue
Fixes #6211
Fixes #6236
Types of changes
Checklist: