我该如何解决:"RCTBridge required dispatch_sync to load" 在 React Native 中使用纱线工作区?
How can i solve: "RCTBridge required dispatch_sync to load" in React Native using yarn workspaces?
我关注媒体文章:React Native 0.63 Monorepo walkthrough 小心地让 yarn 工作区与 react-native 一起工作。 Everhtings 工作,我可以构建我的 iOS 和 Android 应用程序,Metro Bundler 也可以工作,但是当我使用 [=12 构建我的 iOS 应用程序时,我从 Metro 捆绑器收到以下警告=]
RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
除非我将 react-native 与 yarn 工作区一起使用,否则我不会收到此警告。因此,我怀疑错误是由我的 monorepo 设置产生的。
你知道如何删除这个警告吗?
重新打开终端并重新构建应用程序后,警告不再出现
打开你的/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
...
}
来源here
初始打开./ios/{YourAppName}/AppDelegate.m
,在#import "AppDelegate.h"
后添加如下内容
#if RCT_DEV
#import
#endif
然后在@implementation AppDelegate
之前RCTRootView *rootView = ....
添加下面的
#if RCT_DEV
[bridge moduleForClass:[RCTDevLoadingView class]];
#endif
最后,重新打开终端并再次yarn run ios
或npm run ios
。
我关注媒体文章:React Native 0.63 Monorepo walkthrough 小心地让 yarn 工作区与 react-native 一起工作。 Everhtings 工作,我可以构建我的 iOS 和 Android 应用程序,Metro Bundler 也可以工作,但是当我使用 [=12 构建我的 iOS 应用程序时,我从 Metro 捆绑器收到以下警告=]
RCTBridge required dispatch_sync to load RCTDevLoadingView. This may lead to deadlocks
除非我将 react-native 与 yarn 工作区一起使用,否则我不会收到此警告。因此,我怀疑错误是由我的 monorepo 设置产生的。
你知道如何删除这个警告吗?
重新打开终端并重新构建应用程序后,警告不再出现
打开你的/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
...
}
来源here
初始打开
后添加如下内容./ios/{YourAppName}/AppDelegate.m
,在#import "AppDelegate.h"
#if RCT_DEV #import
#endif 然后在
@implementation AppDelegate
之前RCTRootView *rootView = ....
添加下面的#if RCT_DEV [bridge moduleForClass:[RCTDevLoadingView class]]; #endif
最后,重新打开终端并再次
yarn run ios
或npm run ios
。