fix: error handling on empty array
🐛 Issue
When the items array is empty, the roadmap component renders an unintended "0" character on the UI. This happens due to conditional rendering logic evaluating to a numeric value instead of returning null.
✅ Fix Updated the component’s rendering logic to explicitly handle the empty state.
- When items.length == 0, the component now returns null
- Prevents any unintended visual output
- Ensures consistent and predictable rendering behavior
🔄 Before
A "0" character was displayed on the roadmap page when the items array was empty.
✨ After
- The component renders nothing when the items array is empty, as expected.
🧪 Testing
- Verified rendering with:
- Empty items array
- Non-empty items array
- Confirmed no regression in existing behavior
Related issue(s)
Fixes for #4729
Summary by CodeRabbit
-
Bug Fixes
- Improved empty state handling to display a placeholder message instead of blank areas when no content is available.
✏️ Tip: You can customize this high-level summary in your review settings.
Deploy Preview for asyncapi-website ready!
Built without sensitive environment variables
| Name | Link |
|---|---|
| Latest commit | 018b8dab61953459f2774a433687364be9409719 |
| Latest deploy log | https://app.netlify.com/projects/asyncapi-website/deploys/694d0af7e0d5e7000846ef63 |
| Deploy Preview | https://deploy-preview-4747--asyncapi-website.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.
Walkthrough
Added an early guard condition in RoadmapList to handle empty or undefined items by rendering a placeholder paragraph ("🛠 Actively Developing") instead of proceeding with list rendering. Existing behavior is preserved when items are present. No public API changes.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Conditional Rendering for Empty Statecomponents/roadmap/RoadmapList.tsx |
Added early guard to render placeholder paragraph when items are empty or undefined; preserves existing list rendering for non-empty items |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~8 minutes
- Single-file change with straightforward conditional logic
- Verify placeholder text is appropriate and consistent with design language
- Confirm empty/undefined conditions are correctly handled
Possibly related issues
-
asyncapi/website#4729: Both changes affect the same component (
components/roadmap/RoadmapList.tsx) and address conditional rendering behavior for empty or undefined items—this PR may directly resolve or relate to that issue's objectives.
Poem
🐰✨ A rabbit hopped through empty states,
With guards so swift, no more it waits—
"Actively Developing!" now the cry,
When lists are bare, a placeholder spry! 🛠️
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'fix: error handling on empty array' directly addresses the main change: adding guard logic to handle empty items in RoadmapList, which prevents unintended rendering when the array is empty. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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 @coderabbitai help to get the list of available commands and usage tips.
⚡️ Lighthouse report for the changes in this PR:
| Category | Score |
|---|---|
| 🔴 Performance | 38 |
| 🟢 Accessibility | 98 |
| 🟢 Best practices | 92 |
| 🟢 SEO | 100 |
| 🔴 PWA | 33 |
Lighthouse ran on https://deploy-preview-4747--asyncapi-website.netlify.app/
Hi @Ayush4958, thanks for the effort on this PR 🙌 Just a quick note — the same issue was already fixed and merged in #4745, so this PR may be a duplicate.