我在日志中得到这个:
RCTBridge需要dispatch_sync来加载RCTDevLoadingView。这可能 导致死锁
这导致了React中呈现的内容导致对齐问题的问题。
(见附页截图1)Screenshot with Issue
这是随机发生的,因为所有屏幕都没有显示对齐问题。
(见附页截图2)Screenshot without issue
我在布局中使用了样式组件:
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>
)
感谢。
答案 0 :(得分:14)
我修改了AppDelegate.m
,如下所示:
#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]; ... }
来源: devburmistro的回答2017年12月10日来自:https://github.com/facebook/react-native/issues/16376
答案 1 :(得分:3)
使用 React Native Navigation 时,像这样修改您的 AppDelegate.m 文件:
// Add this
#if RCT_DEV
#import <React/RCTDevLoadingView.h>
#endif
// ...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef FB_SONARKIT_ENABLED
InitializeFlipper(application);
#endif
[ReactNativeNavigation bootstrapWithDelegate:self launchOptions:launchOptions];
// Add this
#if RCT_DEV
[[ReactNativeNavigation getBridge] moduleForClass:[RCTDevLoadingView class]];
#endif
return YES;
}
答案 2 :(得分:0)
快速解决方案
let bridge = RCTBridge(bundleURL: jsCodeLocation, moduleProvider: nil, launchOptions: nil)
#if RCT_DEV
bridge?.module(for: RCTDevLoadingView.self)
#endif
let rootView = RCTRootView(bridge: bridge!, moduleName: "AppMain", initialProperties: nil)
答案 3 :(得分:-1)
If you just connect your app to a Firebase instance. then update your AppDelegate.m with
(in Objective C) - (BOOL)application:(UIApplication *)application customDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if(![FIRApp defaultApp]){
[FIRApp configure];}}
}
instead of just adding [FIRApp configure];
(in Swift) func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if FirebaseApp.app() == nil {
FirebaseApp.configure()
}
return true
}