From a509fa989ca9feca008b1339312ef5be713faaa2 Mon Sep 17 00:00:00 2001 From: Sam He Date: Thu, 10 Oct 2024 23:43:51 +0800 Subject: [PATCH] fix: prevent crash when version is missing in data using optional chaining --- src/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 2e1a619..c5188e6 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -37,7 +37,7 @@ export interface Block { export interface DataProp { time: number; - version: string; + version?: string; blocks: Block[]; } @@ -68,7 +68,7 @@ const Blocks = ({ ...renderers, }; - const hasBlockId = data.version?.includes('2.21'); + const hasBlockId = data?.version?.includes('2.21'); return ( <>