mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
[ReactNative] Prevent RCTDevLoadingView from creating UIWindow on unit tests
Summary: `RCTDevLoadingView` was being created from a constructor function and creating a `UIWindow` when the bridge started loading. The `UIWindow` was crashing on the unit tests since there's no host app.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#import "RCTBridge.h"
|
#import "RCTBridge.h"
|
||||||
#import "RCTDevLoadingView.h"
|
#import "RCTDevLoadingView.h"
|
||||||
#import "RCTDefines.h"
|
#import "RCTDefines.h"
|
||||||
|
#import "RCTUtils.h"
|
||||||
|
|
||||||
#if RCT_DEV
|
#if RCT_DEV
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ static void RCTDevLoadingViewSetup()
|
|||||||
|
|
||||||
- (instancetype)init
|
- (instancetype)init
|
||||||
{
|
{
|
||||||
if (self = [super init]) {
|
if ((self = [super init]) && !RCTRunningInTestEnvironment()) {
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(willStartLoading:)
|
selector:@selector(willStartLoading:)
|
||||||
name:RCTJavaScriptWillStartLoadingNotification
|
name:RCTJavaScriptWillStartLoadingNotification
|
||||||
|
|||||||
Reference in New Issue
Block a user