From b7b6a4fc5374cd0fcc3e2c1b93f4b8563b1cf041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=81opaci=C5=84ski?= Date: Mon, 26 Feb 2024 09:43:58 +0100 Subject: [PATCH] fix: Add missing nan value checks for bounds size (#2220) This PR adds missing checks whether SVG bounds size values are nan. This PR should fix [this](https://github.com/software-mansion/react-native-svg/issues/978) old issue that still happens sometimes. --- apple/RNSVGRenderable.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apple/RNSVGRenderable.mm b/apple/RNSVGRenderable.mm index ca9a82447..b245afd33 100644 --- a/apple/RNSVGRenderable.mm +++ b/apple/RNSVGRenderable.mm @@ -475,7 +475,9 @@ - (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect CGPoint mid = CGPointMake(CGRectGetMidX(pathBounds), CGRectGetMidY(pathBounds)); CGPoint center = CGPointApplyAffineTransform(mid, matrix); - self.bounds = bounds; + if (!isnan(bounds.size.width) && !isnan(bounds.size.height)) { + self.bounds = bounds; + } if (!isnan(center.x) && !isnan(center.y)) { self.center = center; }