diff --git a/ios/RNViewShot.mm b/ios/RNViewShot.mm index 2cf632fb..97c62960 100644 --- a/ios/RNViewShot.mm +++ b/ios/RNViewShot.mm @@ -15,6 +15,21 @@ #import #endif +#if __has_include() + + // Fabric available + #import + typedef RCTScrollViewComponentView RNSnapshotScrollViewHost; + +#else + + // Fallback to legacy + #import + typedef RCTScrollView RNSnapshotScrollViewHost; + +#endif + + @implementation RNViewShot RCT_EXPORT_MODULE() @@ -80,12 +95,15 @@ - (dispatch_queue_t)methodQueue UIView* rendered; UIScrollView* scrollView; if (snapshotContentContainer) { - if (![view isKindOfClass:[RCTScrollView class]]) { - reject(RCTErrorUnspecified, [NSString stringWithFormat:@"snapshotContentContainer can only be used on a RCTScrollView. instead got: %@", view], nil); + if (![view isKindOfClass:[RNSnapshotScrollViewHost class]]) { + reject(RCTErrorUnspecified, + [NSString stringWithFormat:@"snapshotContentContainer can only be used on a ScrollView host. instead got: %@", view], + nil); return; } - RCTScrollView* rctScrollView = view; - scrollView = rctScrollView.scrollView; + + RNSnapshotScrollViewHost *host = (RNSnapshotScrollViewHost *)view; + UIScrollView *scrollView = host.scrollView; rendered = scrollView; } else {