From efe0a3f79c8376e995fcd9e920182506c84bb876 Mon Sep 17 00:00:00 2001 From: Kaj Kowalski Date: Sun, 13 Jul 2025 16:24:27 +0200 Subject: [PATCH] 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 --- components/examples/TRPCDemo.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/examples/TRPCDemo.tsx b/components/examples/TRPCDemo.tsx index c47a260..1c4c48e 100644 --- a/components/examples/TRPCDemo.tsx +++ b/components/examples/TRPCDemo.tsx @@ -150,7 +150,7 @@ export function TRPCDemo() { ) : (
- {overview?.sentimentDistribution.map((item) => ( + {overview?.sentimentDistribution?.map((item) => (
) : (
- {sessions?.sessions.map((session) => ( + {sessions?.sessions?.map((session) => (