Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i solve: "RCTBridge required dispatch_sync to load" in React Native using yarn workspaces?

i follow the medium article: React Native 0.63 Monorepo walkthrough carefully to get yarn workspaces works with react-native. Everhtings works, i can build my iOS und Android App and also the Metro Bundler works, but i get the following warning from the metro bundler when i build my iOS App with yarn workspace mobile ios

RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks

I don't get this warning unless I use react-native with yarn workspaces. Therefore, I suspect that the error is generated by my monorepo setup.

Do you have any idea how I can remove this warning?

like image 267
Niklas Avatar asked Apr 14 '21 14:04

Niklas


2 Answers

Open Your /ios/YourAppName/AppDelegate.m

#import "AppDelegate.h"

// ADD THIS
#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif
// TILL HERE

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

...
  RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
                                            moduleProvider:nil
                                             launchOptions:launchOptions];
// THIS CONDITION
#if RCT_DEV
  [bridge moduleForClass:[RCTDevLoadingView class]];
#endif
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                   moduleName:@"Test"
                                            initialProperties:nil];
// TILL HERE
  ...
}

source here

like image 195
Hussain Pettiwala Avatar answered Oct 17 '22 21:10

Hussain Pettiwala


  • Initially open ./ios/{YourAppName}/AppDelegate.m and add the following after the #import "AppDelegate.h"

    #if RCT_DEV #import <React/RCTDevLoadingView.h> #endif

  • Then in the @implementation AppDelegate before the RCTRootView *rootView = .... add the following

    #if RCT_DEV
      [bridge moduleForClass:[RCTDevLoadingView class]];
    #endif 
    
  • Finally, reopen the terminal and yarn run ios or npm run ios again.

like image 40
Akella Niranjan Avatar answered Oct 17 '22 19:10

Akella Niranjan