Niklas
Niklas

Reputation: 1798

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?

Upvotes: 8

Views: 11446

Answers (3)

Akella Niranjan
Akella Niranjan

Reputation: 105

  • 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.

Upvotes: 1

Hussain Pettiwala
Hussain Pettiwala

Reputation: 1674

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

Upvotes: 21

Niklas
Niklas

Reputation: 1798

After reopen the terminal and build the app again, the warning no longer appeared

Upvotes: 0

Related Questions