Kaynağa Gözat

Fixes crash after multiple setRoot

yogevbd 6 yıl önce
ebeveyn
işleme
cb11b6b42a
3 değiştirilmiş dosya ile 16 ekleme ve 9 silme
  1. 1
    0
      lib/ios/RNNCommandsHandler.m
  2. 9
    8
      lib/ios/RNNStore.h
  3. 6
    1
      lib/ios/RNNStore.m

+ 1
- 0
lib/ios/RNNCommandsHandler.m Dosyayı Görüntüle

@@ -55,6 +55,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
55 55
 	[self assertReady];
56 56
 	
57 57
 	[_modalManager dismissAllModalsAnimated:NO];
58
+	[_store removeAllComponents];
58 59
 	
59 60
 	UIViewController *vc = [_controllerFactory createLayoutAndSaveToStore:layout[@"root"]];
60 61
 	

+ 9
- 8
lib/ios/RNNStore.h Dosyayı Görüntüle

@@ -10,19 +10,20 @@ typedef void (^RNNTransitionRejectionBlock)(NSString *code, NSString *message, N
10 10
 
11 11
 @interface RNNStore : NSObject
12 12
 
13
--(UIViewController*) findComponentForId:(NSString*)componentId;
14
--(void) setComponent:(UIViewController*)viewController componentId:(NSString*)componentId;
15
--(void) removeComponent:(NSString*)componentId;
16
--(void) removeComponentByViewControllerInstance:(UIViewController*)componentInstance;
13
+- (UIViewController*)findComponentForId:(NSString*)componentId;
14
+- (void)setComponent:(UIViewController*)viewController componentId:(NSString*)componentId;
15
+- (void)removeComponent:(NSString*)componentId;
16
+- (void)removeComponentByViewControllerInstance:(UIViewController*)componentInstance;
17
+- (void)removeAllComponents;
17 18
 
18 19
 - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
19 20
 - (UIViewController *)getExternalComponent:(NSString *)name props:(NSDictionary*)props bridge:(RCTBridge*)bridge;
20 21
 
21
--(NSString*)componentKeyForInstance:(UIViewController*)instance;
22
+- (NSString*)componentKeyForInstance:(UIViewController*)instance;
22 23
 
23
--(void) setReadyToReceiveCommands:(BOOL)isReady;
24
--(BOOL) isReadyToReceiveCommands;
24
+- (void)setReadyToReceiveCommands:(BOOL)isReady;
25
+- (BOOL)isReadyToReceiveCommands;
25 26
 
26
--(void) clean;
27
+- (void)clean;
27 28
 
28 29
 @end

+ 6
- 1
lib/ios/RNNStore.m Dosyayı Görüntüle

@@ -43,6 +43,11 @@
43 43
 	}
44 44
 }
45 45
 
46
+- (void)removeAllComponents {
47
+	[_componentStore removeAllObjects];
48
+}
49
+
50
+
46 51
 -(void)setReadyToReceiveCommands:(BOOL)isReady {
47 52
 	_isReadyToReceiveCommands = isReady;
48 53
 }
@@ -53,7 +58,7 @@
53 58
 
54 59
 -(void)clean {
55 60
 	_isReadyToReceiveCommands = false;
56
-	[_componentStore removeAllObjects];
61
+	[self removeAllComponents];
57 62
 }
58 63
 
59 64
 -(NSString*)componentKeyForInstance:(UIViewController*)instance {