Fix exception when Text children are empty and scaleToFit=true#6282
Fix exception when Text children are empty and scaleToFit=true#6282
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an exception that occurs when Text components have empty children and scaleToFit=true. The fix adds a guard condition to return null early when there are no words to render, preventing downstream errors.
- Added early return condition when wordsByLines is empty
- Added comprehensive test coverage for scaleToFit functionality
- Added specific test case for empty children scenario
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/component/Text.tsx | Added guard condition to prevent rendering when no text content exists |
| test/component/Text.spec.tsx | Added test suite covering scaleToFit behavior including edge case with empty children |
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 #6282 +/- ##
==========================================
+ Coverage 96.61% 96.63% +0.01%
==========================================
Files 221 221
Lines 20157 20157
Branches 4134 4137 +3
==========================================
+ Hits 19475 19478 +3
+ Misses 675 672 -3
Partials 7 7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 72 bytes (0.0%) ⬆️. 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:
|
Description
Text requires children but it doesn't need to throw errors if children are empty does it.
Related Issue
Fixes #6190