gre / react-native-view-shot

Snapshot a React Native view and save it to an image

Home Page:https://github.com/gre/react-native-view-shot-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: No view found with reactTag with new architecture

ErHarinderSingh opened this issue · comments

Hi there,
I am getting error No view found with reactTag but only with new architecture.
Same error in both Android & iOS.
Anyone? How to resolve it?

Screenshot 2023-04-15 at 13 42 54

I think it's because findNodeHandle is not compatible with React 18. Deprecation of findNodeHandle in React Native is similar to the deprecation of findDOMNode in React DOM.

And the thing is react-native-view-shot uses findNodeHandle
Here is the link :
https://reactnative.dev/docs/0.70/new-architecture-library-intro#preparing-your-javascript-codebase-for-the-new-react-native-renderer-fabric

@gre make attention please.

viewRegistry[target]
is coming as null inside iOS Native Module RNViewShow.m

It looks like the native code is going to have be rewritten to support the new Fabric architecture.

It seems the following code (for iOS) needs to be written using the "Fabric Native Components" methodology:

https://reactnative.dev/docs/the-new-architecture/pillars-fabric-components

RCT_EXPORT_METHOD(captureRef:(nonnull NSNumber *)target
                  withOptions:(NSDictionary *)options
                  resolve:(RCTPromiseResolveBlock)resolve
                  reject:(RCTPromiseRejectBlock)reject)
{
  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {

    // Get view
    UIView *view;

    if ([target intValue] == -1) {
      UIWindow *window = [[UIApplication sharedApplication] keyWindow];
      view = window;
    } else {
      view = viewRegistry[target];
    }

    if (!view) {
      reject(RCTErrorUnspecified, [NSString stringWithFormat:@"No view found with reactTag: %@", target], nil);
      return;
    }

node_modules/react-native-view-shot/ios/RNViewShot.m

Yeah, And same for android @faceyspacey

Hi @gre, anyone taking care of it? It's critical. Totally broken on new architecture.

Any update on this one? The new architecture is a no go with this package. @gre

We are facing this from 0.70.x. Now we are at 0.73.x and the issue is still there for new architecture. New architecture is mandatory now. Someone has to focus on this issue. React Native Skia is also capturing screenshot images. Someone can refer to the code changes from there.
Cc : @gre

capture not working in Android new architecture.

Need this too.

Any updates on this? For me iOS works fine but Android does not.

i have same issue on ios
image

@rabbitmouse

i have same issue on ios image

have you found a workaround for this issue, I only found out that the addUIBlock is no longer working with the newArch enabled, i'm looking for alternatives

Here the fix for this library:

Please note that this would work only from 0.74.0-rc5 onwards (which is going to be published on Monday)