fix(Tooltip): prevent crash on sparse or undefined payload entries#7149
fix(Tooltip): prevent crash on sparse or undefined payload entries#7149ckifer merged 1 commit intorecharts:mainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
WalkthroughThe PR adds defensive handling in Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
8d426a9 to
a25c73f
Compare
Bundle ReportChanges will decrease total bundle size by 740 bytes (-0.01%) ⬇️. This is within the configured threshold ✅ Detailed changes
ℹ️ *Bundle size includes cached data from a previous commit Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-es6Assets Changed:
view changes for bundle: recharts/bundle-treeshaking-sunburstAssets Changed:
view changes for bundle: recharts/bundle-treeshaking-sankeyAssets Changed:
view changes for bundle: recharts/bundle-cjsAssets Changed:
view changes for bundle: recharts/bundle-umdAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7149 +/- ##
==========================================
+ Coverage 89.61% 89.63% +0.02%
==========================================
Files 536 536
Lines 40479 40484 +5
Branches 5519 5525 +6
==========================================
+ Hits 36275 36288 +13
+ Misses 4196 4188 -8
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a25c73f to
1a9a7ad
Compare
What is the purpose of this pull request?
This PR fixes a fatal crash (
TypeError: Cannot read properties of undefined/null (reading 'type')) in theDefaultTooltipContentcomponent.Currently, if the
payloadarray contains sparse items,null, orundefined(e.g.,[ { name: 'A', value: 10 }, undefined, { name: 'B', value: 20 } ]), the component attempts to accessentry.typeduring thesortedPayload.mapexecution without verifying ifentryitself exists, causing the entire React tree to crash.What does this PR do?
sortedPayload.mapto handle and returnnullfor undefined/null entries before accessing their properties.DefaultTooltipContent.spec.tsxthat explicitly mounts the component with a sparse payload to prevent future regressions.Checklist:
mainvia CI).Summary by CodeRabbit