Skip to content

Commit 55213f8

Browse files
authored
feat(fabric): Make all Views layer-backed (#2724)
1 parent 1ae9a89 commit 55213f8

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/react-native/React/Base/macOS/RCTUIKit.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ @implementation RCTUIView
129129
BOOL _clipsToBounds;
130130
BOOL _userInteractionEnabled;
131131
BOOL _mouseDownCanMoveWindow;
132+
BOOL _respondsToDisplayLayer;
132133
}
133134

134135
+ (NSSet<NSString *> *)keyPathsForValuesAffectingValueForKey:(NSString *)key
@@ -158,6 +159,7 @@ @implementation RCTUIView
158159
self->_userInteractionEnabled = YES;
159160
self->_enableFocusRing = YES;
160161
self->_mouseDownCanMoveWindow = YES;
162+
self->_respondsToDisplayLayer = [self respondsToSelector:@selector(displayLayer:)];
161163
}
162164
return self;
163165
}
@@ -259,7 +261,12 @@ - (void)updateLayer
259261
// so it has to be reset from the view's NSColor ivar.
260262
[layer setBackgroundColor:[_backgroundColor CGColor]];
261263
}
262-
[(id<CALayerDelegate>)self displayLayer:layer];
264+
265+
// In Fabric, wantsUpdateLayer is always enabled and doesn't guarantee that
266+
// the instance has a displayLayer method.
267+
if (_respondsToDisplayLayer) {
268+
[(id<CALayerDelegate>)self displayLayer:layer];
269+
}
263270
}
264271

265272
- (void)drawRect:(CGRect)rect

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,6 +2025,11 @@ - (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN
20252025
return RCTNSStringFromString([[self class] componentDescriptorProvider].name);
20262026
}
20272027

2028+
- (BOOL)wantsUpdateLayer
2029+
{
2030+
return YES;
2031+
}
2032+
20282033
@end
20292034

20302035
#ifdef __cplusplus

0 commit comments

Comments
 (0)