diff --git a/packages/react-native/React/Base/macOS/RCTUIKit.m b/packages/react-native/React/Base/macOS/RCTUIKit.m index 042c64b94fda23..08e6c95545ac6d 100644 --- a/packages/react-native/React/Base/macOS/RCTUIKit.m +++ b/packages/react-native/React/Base/macOS/RCTUIKit.m @@ -129,6 +129,7 @@ @implementation RCTUIView BOOL _clipsToBounds; BOOL _userInteractionEnabled; BOOL _mouseDownCanMoveWindow; + BOOL _respondsToDisplayLayer; } + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key @@ -158,6 +159,7 @@ @implementation RCTUIView self->_userInteractionEnabled = YES; self->_enableFocusRing = YES; self->_mouseDownCanMoveWindow = YES; + self->_respondsToDisplayLayer = [self respondsToSelector:@selector(displayLayer:)]; } return self; } @@ -259,7 +261,12 @@ - (void)updateLayer // so it has to be reset from the view's NSColor ivar. [layer setBackgroundColor:[_backgroundColor CGColor]]; } - [(id)self displayLayer:layer]; + + // In Fabric, wantsUpdateLayer is always enabled and doesn't guarantee that + // the instance has a displayLayer method. + if (_respondsToDisplayLayer) { + [(id)self displayLayer:layer]; + } } - (void)drawRect:(CGRect)rect diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index 08fd12bbd59325..af394b1535ddf7 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -2025,6 +2025,11 @@ - (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN return RCTNSStringFromString([[self class] componentDescriptorProvider].name); } +- (BOOL)wantsUpdateLayer +{ + return YES; +} + @end #ifdef __cplusplus