Skip to content

IOS RCTScrollView x RCTScrollViewComponentView error patch-fix. #575

@Hasan-Jafri

Description

@Hasan-Jafri

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Basically, this is a patch only for IOS where RCTScrollView is required for long screenCapture when snapshotContentContainer is true, it checks for this component and when it does not find it, raises an error "snapshotContentContainer can only be used on a RCTScrollView. instead got something something.......".

Now this is a temporary fix :), if you want to keep long screenshots on IOS without any issue, I will not recommend it until and unless there is no other option :). I created this because I think it should be known, I don't know if its good or bad, but for time being this works OK.

You can try and use the patch.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-view-shot/ios/RNViewShot.mm b/node_modules/react-native-view-shot/ios/RNViewShot.mm
index 2cf632f..b53897b 100644
--- a/node_modules/react-native-view-shot/ios/RNViewShot.mm
+++ b/node_modules/react-native-view-shot/ios/RNViewShot.mm
@@ -4,7 +4,7 @@
 #import <React/UIView+React.h>
 #import <React/RCTUtils.h>
 #import <React/RCTConvert.h>
-#import <React/RCTScrollView.h>
+#import <React/RCTScrollViewComponentView.h>
 #import <React/RCTUIManager.h>
 #if __has_include(<React/RCTUIManagerUtils.h>)
 #import <React/RCTUIManagerUtils.h>
@@ -80,12 +80,12 @@ - (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);
-        return;
-      }
-      RCTScrollView* rctScrollView = view;
-      scrollView = rctScrollView.scrollView;
+      // if (![view isKindOfClass:[RCTScrollViewComponentView class]]) {
+      //   reject(RCTErrorUnspecified, [NSString stringWithFormat:@"snapshotContentContainer can only be used on a RCTScrollView. instead got: %@", view], nil);
+      //   return;
+      // }
+      RCTScrollViewComponentView* RCTScrollViewComponentView = view;
+      scrollView = RCTScrollViewComponentView.scrollView;
       rendered = scrollView;
     }
     else {

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions