react-native-view-shot icon indicating copy to clipboard operation
react-native-view-shot copied to clipboard

Error: No view found with reactTag with new architecture

Open ErHarinderSingh opened this issue 1 year ago • 12 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

ErHarinderSingh avatar Apr 15 '23 08:04 ErHarinderSingh

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

ErHarinderSingh avatar Apr 17 '23 08:04 ErHarinderSingh

@gre make attention please.

ErHarinderSingh avatar Apr 17 '23 08:04 ErHarinderSingh

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

ErHarinderSingh avatar Apr 17 '23 09:04 ErHarinderSingh

+1

faceyspacey avatar Apr 21 '23 07:04 faceyspacey

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

faceyspacey avatar Apr 21 '23 08:04 faceyspacey

Yeah, And same for android @faceyspacey

ErHarinderSingh avatar Apr 21 '23 08:04 ErHarinderSingh

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

ErHarinderSingh avatar Jul 10 '23 08:07 ErHarinderSingh

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

skinsapp avatar Aug 17 '23 04:08 skinsapp

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

ErHarinderSingh avatar Dec 02 '23 05:12 ErHarinderSingh

capture not working in Android new architecture.

rohit-jindal018 avatar Dec 11 '23 06:12 rohit-jindal018

Need this too.

faceyspacey avatar Dec 20 '23 03:12 faceyspacey

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

uzaymacar avatar Feb 01 '24 21:02 uzaymacar

i have same issue on ios image

rabbitmouse avatar Mar 14 '24 03:03 rabbitmouse

@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

L0rdCr1s avatar Mar 14 '24 15:03 L0rdCr1s

Here the fix for this library:

  • https://github.com/gre/react-native-view-shot/pull/516

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

cortinico avatar Mar 21 '24 13:03 cortinico