mirror of
https://github.com/kjanat/livedash-node.git
synced 2026-01-16 12:32:10 +01:00
fix: add null checks for array mapping in TRPCDemo component
- Add optional chaining to sentimentDistribution?.map() to prevent runtime errors - Add optional chaining to sessions?.sessions?.map() for consistency - Both properties can be null/undefined and need protection before mapping - Prevents 'Cannot read property map of undefined' errors
This commit is contained in:
@ -150,7 +150,7 @@ export function TRPCDemo() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
{overview?.sentimentDistribution.map((item) => (
|
{overview?.sentimentDistribution?.map((item) => (
|
||||||
<div
|
<div
|
||||||
key={item.sentiment}
|
key={item.sentiment}
|
||||||
className="flex justify-between text-sm"
|
className="flex justify-between text-sm"
|
||||||
@ -226,7 +226,7 @@ export function TRPCDemo() {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{sessions?.sessions.map((session) => (
|
{sessions?.sessions?.map((session) => (
|
||||||
<div key={session.id} className="border rounded-lg p-4">
|
<div key={session.id} className="border rounded-lg p-4">
|
||||||
<div className="flex items-center justify-between mb-2">
|
<div className="flex items-center justify-between mb-2">
|
||||||
<div className="flex items-center space-x-2">
|
<div className="flex items-center space-x-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user