首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RCTBridge需要dispatch_sync来加载RCTDevLoadingView。这可能会导致死锁

RCTBridge需要dispatch_sync来加载RCTDevLoadingView。这可能会导致死锁
EN

Stack Overflow用户
提问于 2017-08-31 18:40:32
回答 6查看 42.5K关注 0票数 57

我把这个写在日志里:

RCTBridge需要dispatch_sync来加载RCTDevLoadingView。这可能会导致死锁

这将导致React中呈现的内容导致对齐问题。

(见附件截图1) 有问题的截图

这是随机发生的,因为所有屏幕都不显示对齐问题。

(见附图2) 无问题截图

我使用了样式-组件的布局:

代码语言:javascript
复制
return(
  this.props.lastComponent ?
  <CommentList marginLeft={this.props.marginLeft}>
    <CommentUserPicWrapper imageWidth={this.props.imageWidth}>
      {this.props.imageType === 'URL' ? <CommentUserPic source={{uri:this.props.uri}} imageWidth={this.props.imageWidth} onLoad={this.handleLoad}/> : <CommentUserPic source={require('../../img/defaultProfPic.png')} imageWidth={this.props.imageWidth} onLoad={this.handleLoad}/>}
      {
        this.state.loading ? null : <ActivityIndicator style={{position:'absolute'}}/>
      }
    </CommentUserPicWrapper>
    <CommentDetails borderStatus={true} marginLeft={this.props.marginLeft}>
      <CommentUserName>{this.props.userName} says</CommentUserName>
      <CommentUserContent>{this.props.UserContent}</CommentUserContent>
      <CommentUserDate><Text>{this.props.commentDate}</Text> at <Text>{this.props.commentTime}</Text>MST</CommentUserDate>
    </CommentDetails>
    <CommentReply onPress={this.replyClicked} borderStatus={true} underlayColor='transparent'>
      <CommentReplyText>Reply</CommentReplyText>
    </CommentReply>
  </CommentList>
  :
  <CommentList marginLeft={this.props.marginLeft}>
    <CommentUserPicWrapper imageWidth={this.props.imageWidth}>
      {this.props.imageType === 'URL' ? <CommentUserPic source={{uri:this.props.uri}} imageWidth={this.props.imageWidth} onLoad={this.handleLoad}/> : <CommentUserPic source={require('../../img/defaultProfPic.png')} imageWidth={this.props.imageWidth} onLoad={this.handleLoad}/>}
      {this.state.loading ? null : <ActivityIndicator style={{position:'absolute'}}/>}
    </CommentUserPicWrapper>
    <CommentDetails borderStatus={this.props.borderStatus} marginLeft={this.props.marginLeft}>
      <CommentUserName>{this.props.userName} says</CommentUserName>
      <CommentUserContent>{this.props.UserContent}</CommentUserContent>
      <CommentUserDate><Text>{this.props.commentDate}</Text> at <Text>{this.props.commentTime}</Text>MST</CommentUserDate>
    </CommentDetails>
    <CommentReply onPress={this.replyClicked} borderStatus={this.props.borderStatus} underlayColor='transparent'>
      <CommentReplyText>Reply</CommentReplyText>
    </CommentReply>
  </CommentList>
)

谢谢。

EN

回答 6

Stack Overflow用户

发布于 2018-02-21 10:32:50

我通过更新AppDelegate.m修复了它,如下所示:

代码语言:javascript
复制
   #if RCT_DEV
   #import <React/RCTDevLoadingView.h>
   #endif
   //...

   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
   {
   //...
   RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation
                 moduleProvider:nil
                  launchOptions:launchOptions];
   #if RCT_DEV
   [bridge moduleForClass:[RCTDevLoadingView class]];
   #endif

   RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                    moduleName:@"<AddYourAppNameHere>"
                 initialProperties:nil];
   //...
   }

资料来源:grossingdev的答案2017年12月10日来自:https://github.com/facebook/react-native/issues/16376

票数 64
EN

Stack Overflow用户

发布于 2022-01-29 13:55:12

在导入AppDelegate.h之后添加这一行

代码语言:javascript
复制
#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif

然后,在AppDelegate的实现中,在RCTRootView之前添加以下行:

代码语言:javascript
复制
#if RCT_DEV
[bridge moduleForClass:[RCTDevLoadingView class]];
#endif

现在重建应用程序。错误应该消失了。

如需进一步参考,请访问这里

票数 13
EN

Stack Overflow用户

发布于 2021-11-30 19:48:05

有些答案是正确的,但对某些人来说并不清楚。因为代表对新手来说不容易

  1. 地点:产品名称/产品名称/AppDelegate.m
  2. 仔细编辑该文件,因为如果您错误了任何会生成失败的内容,或者当您重新加载项目时会出现构建失败(所以必须小心):#导入"AppDelegate.h“之后的第一个文件中

#导入"AppDelegate.h“ //如果RCT_DEV #导入 #endif /

RCTRootView *rootView =之前添加

//添加此#if RCT_DEV [桥模块类:RCTDevLoadingView类];#endif //? RCTRootView *rootView =。(默认代码)

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45988103

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档