Browse Source

Fixes crash after multiple setRoot

yogevbd 6 years ago
parent
commit
cb11b6b42a
3 changed files with 16 additions and 9 deletions
  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 View File

55
 	[self assertReady];
55
 	[self assertReady];
56
 	
56
 	
57
 	[_modalManager dismissAllModalsAnimated:NO];
57
 	[_modalManager dismissAllModalsAnimated:NO];
58
+	[_store removeAllComponents];
58
 	
59
 	
59
 	UIViewController *vc = [_controllerFactory createLayoutAndSaveToStore:layout[@"root"]];
60
 	UIViewController *vc = [_controllerFactory createLayoutAndSaveToStore:layout[@"root"]];
60
 	
61
 	

+ 9
- 8
lib/ios/RNNStore.h View File

10
 
10
 
11
 @interface RNNStore : NSObject
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
 - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
19
 - (void)registerExternalComponent:(NSString *)name callback:(RNNExternalViewCreator)callback;
19
 - (UIViewController *)getExternalComponent:(NSString *)name props:(NSDictionary*)props bridge:(RCTBridge*)bridge;
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
 @end
29
 @end

+ 6
- 1
lib/ios/RNNStore.m View File

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