From 54c326b9af96db1266626dfdbf1c04441d036e18 Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Wed, 1 May 2024 18:15:32 -0400 Subject: [PATCH] fix: if layout width is NaN, avoid throwing (#761) --- packages/ui/app/src/components/FernImage.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/ui/app/src/components/FernImage.tsx b/packages/ui/app/src/components/FernImage.tsx index f3b3abf55a..bfbb9cdfc0 100644 --- a/packages/ui/app/src/components/FernImage.tsx +++ b/packages/ui/app/src/components/FernImage.tsx @@ -49,6 +49,12 @@ function getDimensions( ): { width: number; height: number } { layoutWidth = typeof layoutWidth === "string" ? parseInt(layoutWidth, 10) : layoutWidth; layoutHeight = typeof layoutHeight === "string" ? parseInt(layoutHeight, 10) : layoutHeight; + if (layoutWidth != null && isNaN(layoutWidth)) { + layoutWidth = undefined; + } + if (layoutHeight != null && isNaN(layoutHeight)) { + layoutHeight = undefined; + } if (layoutWidth != null && layoutHeight != null) { return { width: layoutWidth, height: layoutHeight }; }