Преглед изворни кода

Fix infinite loop while trying to remove react buttons

Guy Carmeli пре 5 година
родитељ
комит
61a9abeaf1
1 измењених фајлова са 5 додато и 4 уклоњено
  1. 5
    4
      lib/ios/RNNReactComponentRegistry.m

+ 5
- 4
lib/ios/RNNReactComponentRegistry.m Прегледај датотеку

@@ -19,10 +19,10 @@
19 19
 - (RNNReactView *)createComponentIfNotExists:(RNNComponentOptions *)component parentComponentId:(NSString *)parentComponentId reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
20 20
 	NSMutableDictionary* parentComponentDict = [self componentsForParentId:parentComponentId];
21 21
 	
22
-	RNNReactView* reactView = [parentComponentDict objectForKey:component.componentId.get];
22
+	RNNReactView* reactView = parentComponentDict[component.componentId.get];
23 23
 	if (!reactView) {
24 24
 		reactView = (RNNReactView *)[_creator createRootViewFromComponentOptions:component reactViewReadyBlock:reactViewReadyBlock];
25
-		[parentComponentDict setObject:reactView forKey:component.componentId.get];
25
+		parentComponentDict[component.componentId.get] = reactView;
26 26
 	} else if (reactViewReadyBlock) {
27 27
 		reactViewReadyBlock();
28 28
 	}
@@ -50,8 +50,9 @@
50 50
 
51 51
 - (void)removeChildComponent:(NSString *)childId {
52 52
 	NSMutableDictionary* parent;
53
-	while ((parent = _componentStore.objectEnumerator.nextObject)) {
54
-		if ([parent objectForKey:childId]) {
53
+	NSEnumerator *enumerator = _componentStore.objectEnumerator;
54
+	while ((parent = enumerator.nextObject)) {
55
+		if (parent[childId]) {
55 56
 			[parent removeObjectForKey:childId];
56 57
 			return;
57 58
 		}