From 3cba1472e6ec9e02852d276e3fee8f4d16eac0ec Mon Sep 17 00:00:00 2001 From: Sam Chau Date: Sat, 18 Jan 2025 17:49:43 +1030 Subject: [PATCH] feat: add type checking for rawKey in formatKey function --- frontend/src/hooks/useChangeParser.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/hooks/useChangeParser.js b/frontend/src/hooks/useChangeParser.js index 23f4837..9a53bdf 100644 --- a/frontend/src/hooks/useChangeParser.js +++ b/frontend/src/hooks/useChangeParser.js @@ -22,6 +22,12 @@ function formatSegment(segment) { } function formatKey(rawKey) { + // Add type checking + if (typeof rawKey !== 'string') { + console.warn('Expected string for key, received:', rawKey); + return String(rawKey || ''); // Convert to string or use empty string as fallback + } + const segments = rawKey.split('.'); const formattedSegments = segments.map(segment => formatSegment(segment)); return formattedSegments.join(': ');