Skip to content

Commit d30f249

Browse files
fix: null shadow color crash (#2672)
## Summary: When updating RCTView in #2642, we end up slightly changing the behavior when `didUpdateShadow` is called, causing transparent shadows to crash the app. This breakage occurs because `NSColor colorWithCGColor:` doesn’t accept a `NULL` `CGColorRef`; instead, it raises an exception rather than gracefully returning `nil`. <img height="698" alt="image" src="https://github.com/user-attachments/assets/67413d6e-47e8-47b3-8b29-b9b553cfd19f" /> ## Test Plan: Run RNTester
1 parent a0d76f3 commit d30f249

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/react-native/React/Views/RCTView.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,10 @@ - (void)setShadowRadius:(CGFloat)shadowRadius
764764
-(void)didUpdateShadow
765765
{
766766
NSShadow *shadow = [NSShadow new];
767-
NSColor *baseShadowColor = [NSColor colorWithCGColor:_shadowColor];
767+
NSColor *baseShadowColor = nil;
768+
if (_shadowColor != NULL) {
769+
baseShadowColor = [NSColor colorWithCGColor:_shadowColor];
770+
}
768771
shadow.shadowColor = [baseShadowColor colorWithAlphaComponent:[self shadowOpacity]];
769772
shadow.shadowOffset = [self shadowOffset];
770773
shadow.shadowBlurRadius = [self shadowRadius];

0 commit comments

Comments
 (0)