File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -590,15 +590,22 @@ - (void)invalidate
590
590
591
591
// Invalidate modules
592
592
dispatch_group_t group = dispatch_group_create ();
593
- for (RCTModuleData *moduleData in _moduleDataByName.allValues ) {
594
- if (moduleData.instance == _javaScriptExecutor) {
593
+ for (RCTModuleData *moduleData in _moduleDataByID) {
594
+ // Be careful when grabbing an instance here, we don't want to instantiate
595
+ // any modules just to invalidate them.
596
+ id <RCTBridgeModule> instance = nil ;
597
+ if ([moduleData hasInstance ]) {
598
+ instance = moduleData.instance ;
599
+ }
600
+
601
+ if (instance == _javaScriptExecutor) {
595
602
continue ;
596
603
}
597
604
598
- if ([moduleData. instance respondsToSelector: @selector (invalidate )]) {
605
+ if ([instance respondsToSelector: @selector (invalidate )]) {
599
606
dispatch_group_enter (group);
600
607
[self dispatchBlock: ^{
601
- [(id <RCTInvalidating>)moduleData. instance invalidate ];
608
+ [(id <RCTInvalidating>)instance invalidate ];
602
609
dispatch_group_leave (group);
603
610
} queue: moduleData.methodQueue];
604
611
}
You can’t perform that action at this time.
0 commit comments