From 4dcb62d10b9c99b88ce02b644de692169fce31d2 Mon Sep 17 00:00:00 2001 From: Ake Date: Thu, 12 Feb 2026 16:35:51 +0200 Subject: [PATCH 1/7] Refactor scroll view type handling for snapshots --- ios/RNViewShot.mm | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ios/RNViewShot.mm b/ios/RNViewShot.mm index 2cf632fb..c2722fd0 100644 --- a/ios/RNViewShot.mm +++ b/ios/RNViewShot.mm @@ -15,6 +15,17 @@ #import #endif +// Add these imports near the top: + +#if RCT_NEW_ARCH_ENABLED +#import +typedef RCTScrollViewComponentView RNSnapshotScrollViewHost; +#else +#import +typedef RCTScrollView RNSnapshotScrollViewHost; +#endif + + @implementation RNViewShot RCT_EXPORT_MODULE() @@ -80,12 +91,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(@"E_INVALID_VIEW", + [NSString stringWithFormat:@"snapshotContentContainer can only be used on a ScrollView, got: %@", view], + nil); return; } - RCTScrollView* rctScrollView = view; - scrollView = rctScrollView.scrollView; + + RNSnapshotScrollViewHost *host = (RNSnapshotScrollViewHost *)view; + UIScrollView *scrollView = host.scrollView; rendered = scrollView; } else { From 04b628620d6e8e658844f38d238cfae9202d0484 Mon Sep 17 00:00:00 2001 From: Ake Date: Thu, 12 Feb 2026 16:39:18 +0200 Subject: [PATCH 2/7] Update error message for invalid view in RNViewShot --- ios/RNViewShot.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/RNViewShot.mm b/ios/RNViewShot.mm index c2722fd0..b0cfa9ff 100644 --- a/ios/RNViewShot.mm +++ b/ios/RNViewShot.mm @@ -92,9 +92,9 @@ - (dispatch_queue_t)methodQueue UIScrollView* scrollView; if (snapshotContentContainer) { if (![view isKindOfClass:[RNSnapshotScrollViewHost class]]) { - reject(@"E_INVALID_VIEW", - [NSString stringWithFormat:@"snapshotContentContainer can only be used on a ScrollView, got: %@", view], - nil); + reject(RCTErrorUnspecified, + [NSString stringWithFormat:@"snapshotContentContainer can only be used on a ScrollView host. instead got: %@", view], + nil); return; } From 3852a875881b61f62f01fa06a733d16e8993ee31 Mon Sep 17 00:00:00 2001 From: Ake Date: Thu, 12 Feb 2026 16:46:48 +0200 Subject: [PATCH 3/7] remove legacy elements when RCT_REMOVE_LEGACY_ARCH is set to true --- ios/RNViewShot.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/RNViewShot.mm b/ios/RNViewShot.mm index b0cfa9ff..d6656ae5 100644 --- a/ios/RNViewShot.mm +++ b/ios/RNViewShot.mm @@ -17,7 +17,7 @@ // Add these imports near the top: -#if RCT_NEW_ARCH_ENABLED +#if RCT_REMOVE_LEGACY_ARCH #import typedef RCTScrollViewComponentView RNSnapshotScrollViewHost; #else @@ -92,9 +92,9 @@ - (dispatch_queue_t)methodQueue UIScrollView* scrollView; if (snapshotContentContainer) { if (![view isKindOfClass:[RNSnapshotScrollViewHost class]]) { - reject(RCTErrorUnspecified, - [NSString stringWithFormat:@"snapshotContentContainer can only be used on a ScrollView host. instead got: %@", view], - nil); + reject(@"E_INVALID_VIEW", + [NSString stringWithFormat:@"snapshotContentContainer can only be used on a ScrollView, got: %@", view], + nil); return; } From c36c85f0d193e38121ce42fef5c8739a28961d30 Mon Sep 17 00:00:00 2001 From: Ake Date: Thu, 12 Feb 2026 16:47:44 +0200 Subject: [PATCH 4/7] Improve error message for invalid view type --- ios/RNViewShot.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/RNViewShot.mm b/ios/RNViewShot.mm index d6656ae5..0dda8894 100644 --- a/ios/RNViewShot.mm +++ b/ios/RNViewShot.mm @@ -92,8 +92,8 @@ - (dispatch_queue_t)methodQueue UIScrollView* scrollView; if (snapshotContentContainer) { if (![view isKindOfClass:[RNSnapshotScrollViewHost class]]) { - reject(@"E_INVALID_VIEW", - [NSString stringWithFormat:@"snapshotContentContainer can only be used on a ScrollView, got: %@", view], + reject(RCTErrorUnspecified, + [NSString stringWithFormat:@"snapshotContentContainer can only be used on a ScrollView host. instead got: %@", view], nil); return; } From af450541af6c94d675e9bc06d9821f31333f3cce Mon Sep 17 00:00:00 2001 From: Ake Date: Thu, 12 Feb 2026 16:55:21 +0200 Subject: [PATCH 5/7] Clean up imports in RNViewShot.mm Removed unnecessary comment about imports. --- ios/RNViewShot.mm | 2 -- 1 file changed, 2 deletions(-) diff --git a/ios/RNViewShot.mm b/ios/RNViewShot.mm index 0dda8894..49be46db 100644 --- a/ios/RNViewShot.mm +++ b/ios/RNViewShot.mm @@ -15,8 +15,6 @@ #import #endif -// Add these imports near the top: - #if RCT_REMOVE_LEGACY_ARCH #import typedef RCTScrollViewComponentView RNSnapshotScrollViewHost; From 021116512c318df7699bc45c9f9463b28738ebe3 Mon Sep 17 00:00:00 2001 From: Ake Date: Thu, 12 Feb 2026 17:10:08 +0200 Subject: [PATCH 6/7] Update import statements for new architecture --- ios/RNViewShot.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNViewShot.mm b/ios/RNViewShot.mm index 49be46db..26cd1807 100644 --- a/ios/RNViewShot.mm +++ b/ios/RNViewShot.mm @@ -15,7 +15,7 @@ #import #endif -#if RCT_REMOVE_LEGACY_ARCH +#if RCT_NEW_ARCH_ENABLED #import typedef RCTScrollViewComponentView RNSnapshotScrollViewHost; #else From c4f02004c13a785228dc507985ce8618f1c1291c Mon Sep 17 00:00:00 2001 From: Ake Date: Thu, 12 Feb 2026 17:24:36 +0200 Subject: [PATCH 7/7] use Fabric if available. otherwise fallback to legacy arch Updated conditional imports for RCTScrollViewComponentView based on availability. --- ios/RNViewShot.mm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ios/RNViewShot.mm b/ios/RNViewShot.mm index 26cd1807..97c62960 100644 --- a/ios/RNViewShot.mm +++ b/ios/RNViewShot.mm @@ -15,12 +15,18 @@ #import #endif -#if RCT_NEW_ARCH_ENABLED -#import -typedef RCTScrollViewComponentView RNSnapshotScrollViewHost; +#if __has_include() + + // Fabric available + #import + typedef RCTScrollViewComponentView RNSnapshotScrollViewHost; + #else -#import -typedef RCTScrollView RNSnapshotScrollViewHost; + + // Fallback to legacy + #import + typedef RCTScrollView RNSnapshotScrollViewHost; + #endif